BP_Group_Member_Query::populate_group_member_extras( BP_User_Query $query, string $user_ids_sql )
Fetch additional data required in bp_group_has_members() loops.
Description
Additional data fetched:
- is_banned
- date_modified
Parameters
- $query
-
(Required) BP_User_Query object. Because we're filtering the current object, we use $this inside of the method instead.
- $user_ids_sql
-
(Required) Sanitized, comma-separated string of the user ids returned by the main query.
Source
File: bp-groups/classes/class-bp-group-member-query.php
public function populate_group_member_extras( $query, $user_ids_sql ) { global $wpdb; $bp = buddypress(); $extras = $wpdb->get_results( $wpdb->prepare( "SELECT id, user_id, date_modified, is_admin, is_mod, comments, user_title, invite_sent, is_confirmed, inviter_id, is_banned FROM {$bp->groups->table_name_members} WHERE user_id IN ({$user_ids_sql}) AND group_id = %d", $this->query_vars['group_id'] ) ); foreach ( (array) $extras as $extra ) { if ( isset( $this->results[ $extra->user_id ] ) ) { // The user_id is provided for backward compatibility. $this->results[ $extra->user_id ]->user_id = (int) $extra->user_id; $this->results[ $extra->user_id ]->is_admin = (int) $extra->is_admin; $this->results[ $extra->user_id ]->is_mod = (int) $extra->is_mod; $this->results[ $extra->user_id ]->is_banned = (int) $extra->is_banned; $this->results[ $extra->user_id ]->date_modified = $extra->date_modified; $this->results[ $extra->user_id ]->user_title = $extra->user_title; $this->results[ $extra->user_id ]->comments = $extra->comments; $this->results[ $extra->user_id ]->invite_sent = (int) $extra->invite_sent; $this->results[ $extra->user_id ]->inviter_id = (int) $extra->inviter_id; $this->results[ $extra->user_id ]->is_confirmed = (int) $extra->is_confirmed; $this->results[ $extra->user_id ]->membership_id = (int) $extra->id; } } // Don't filter other BP_User_Query objects on the same page. remove_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10 ); }
Changelog
Version | Description |
---|---|
BuddyPress 1.8.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.