groups_get_group( int $group_id )

Fetch a single group object.

Description

When calling up a group object, you should always use this function instead of instantiating BP_Groups_Group directly, so that you will inherit cache support and pass through the groups_get_group filter.

Parameters

$group_id

(int) (Required) ID of the group.

Return

(BP_Groups_Group) $group The group object.

Source

File: bp-groups/bp-groups-functions.php

function groups_get_group( $group_id ) {
	/*
	 * Backward compatibilty.
	 * Old-style arguments take the form of an array or a query string.
	 */
	if ( ! is_numeric( $group_id ) ) {
		$r = bp_parse_args( $group_id, array(
			'group_id'        => false,
			'load_users'      => false,
			'populate_extras' => false,
		), 'groups_get_group' );

		$group_id = $r['group_id'];
	}

	$group = new BP_Groups_Group( $group_id );

	/**
	 * Filters a single group object.
	 *
	 * @since BuddyPress 1.2.0
	 *
	 * @param BP_Groups_Group $group Single group object.
	 */
	return apply_filters( 'groups_get_group', $group );
}

Changelog

Changelog
Version Description
BuddyPress 1.2.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.