BP_Groups_Group::get_random( int|null $limit = null, int|null $page = null, int $user_id, string|bool $search_terms = false, bool $populate_extras = true, string|array|bool $exclude = false )

Get a list of random groups.

Description

Use BP_Groups_Group::get() with ‘type’ = ‘random’ instead.

Parameters

$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

$user_id

(Optional) If present, groups will be limited to those of which the specified user is a member.

$search_terms

(Optional) Limit groups to those whose name or description field contain the search string.

Default value: false

$populate_extras

(Optional) Whether to fetch extra information about the groups. Default: true.

Default value: true

$exclude

(Optional) Array or comma-separated list of group IDs to exclude from results.

Default value: false

Return

(array)

  • 'groups'
    (array) Array of group objects returned by the paginated query.
  • 'total'
    (int) Total count of all groups matching non- paginated query params.

Source

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

	public static function get_random( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
		$args = array(
			'type'               => 'random',
			'per_page'           => $limit,
			'page'               => $page,
			'user_id'            => $user_id,
			'search_terms'       => $search_terms,
			'exclude'            => $exclude,
		);

		return BP_Groups_Group::get( $args );
	}

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.