BP_Groups_Group::filter_user_groups( string $filter, int $user_id, mixed $order = false, int|null $limit = null, int|null $page = null )

Get a list of a user’s groups, filtered by a search string.


Description Description


Parameters Parameters

$filter

(Required) Search term. Matches against 'name' and 'description' fields.

$user_id

(Required) ID of the user whose groups are being searched. Default: the displayed user.

$order

(Optional) Not used.

Default value: false

$limit

(Optional) The max number of results to return. Default: null (no limit).

Default value: null

$page

(Optional) The page offset of results to return. Default: null (no limit).

Default value: null


Top ↑

Return Return

(false|array)

  • 'groups'
    (array) Array of matched and paginated group IDs.
  • 'total'
    (int) Total count of groups matching the query.


Top ↑

Source Source

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

	public static function filter_user_groups( $filter, $user_id = 0, $order = false, $limit = null, $page = null ) {
		if ( empty( $user_id ) ) {
			$user_id = bp_displayed_user_id();
		}

		$args = array(
			'search_terms' => $filter,
			'user_id'      => $user_id,
			'per_page'     => $limit,
			'page'         => $page,
			'order'        => $order,
		);

		$groups = BP_Groups_Group::get( $args );

		// Modify the results to match the old format.
		$paged_groups = array();
		$i = 0;
		foreach ( $groups['groups'] as $group ) {
			$paged_groups[ $i ] = new stdClass;
			$paged_groups[ $i ]->group_id = $group->id;
			$i++;
		}

		return array( 'groups' => $paged_groups, 'total' => $groups['total'] );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.