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 Description

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

Top ↑

Parameters Parameters


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

Default value: null


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

Default value: null


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


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

Default value: false


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

Default value: true


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

Default value: false

Top ↑

Return Return


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

Source 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 );

Top ↑

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.