BP_Groups_Group::search_groups( string $filter, int|null $limit = null, int|null $page = null, string|bool $sort_by = false, string|bool $order = false )

Get a list of groups, filtered by a search string.


Description Description


Parameters Parameters

$filter

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

$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

$sort_by

(Optional) Column to sort by. Default: false (default sort).

Default value: false

$order

(Optional) ASC or DESC. Default: false (default sort).

Default value: false


Top ↑

Return Return

(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 search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
		$args = array(
			'search_terms' => $filter,
			'per_page'     => $limit,
			'page'         => $page,
			'orderby'      => $sort_by,
			'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.