BP_Groups_Group::get_group_extras( array $paged_groups, string|array $group_ids, string|bool $type = false )

Fetch extra data for a list of groups.

Description

This method is used throughout the class, by methods that take a $populate_extras parameter.

Data fetched:

  • Logged-in user’s status within each group (is_member, is_confirmed, is_pending, is_banned)

Parameters

$paged_groups

(Required) Array of groups.

$group_ids

(Required) Array or comma-separated list of IDs matching $paged_groups.

$type

(Optional) Not used.

Default value: false

Return

(array) $paged_groups

Source

File: bp-groups/classes/class-bp-groups-group.php

	public static function get_group_extras( &$paged_groups, &$group_ids, $type = false ) {
		$user_id = bp_loggedin_user_id();

		foreach ( $paged_groups as &$group ) {
			$group->is_member  = groups_is_user_member( $user_id, $group->id )  ? 1 : 0;
			$group->is_invited = groups_is_user_invited( $user_id, $group->id ) ? 1 : 0;
			$group->is_pending = groups_is_user_pending( $user_id, $group->id ) ? 1 : 0;
			$group->is_banned  = (bool) groups_is_user_banned( $user_id, $group->id );
		}

		return $paged_groups;
	}

Changelog

Changelog
Version Description
BuddyPress 1.6.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.