BP_Groups_Member::__construct( int $user_id, int $group_id, int|bool $id = false, bool $populate = true )

Constructor method.

Description

Parameters

$user_id

(Optional) Along with $group_id, can be used to look up a membership.

$group_id

(Optional) Along with $user_id, can be used to look up a membership.

$id

(Optional) The unique ID of the membership object.

Default value: false

$populate

(Optional) Whether to populate the properties of the located membership. Default: true.

Default value: true

Source

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

146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
public function __construct( $user_id = 0, $group_id = 0, $id = false, $populate = true ) {
 
    // User and group are not empty, and ID is.
    if ( !empty( $user_id ) && !empty( $group_id ) && empty( $id ) ) {
        $this->user_id  = $user_id;
        $this->group_id = $group_id;
 
        if ( !empty( $populate ) ) {
            $this->populate();
        }
    }
 
    // ID is not empty.
    if ( !empty( $id ) ) {
        $this->id = $id;
 
        if ( !empty( $populate ) ) {
            $this->populate();
        }
    }
}

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.