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

(Required) ID of the group.

Return

(BP_Groups_Group) $group The group object.

Source

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

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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.