Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/03/2013 05:12:54 PM (11 years ago)
Author:
boonebgorges
Message:

Introduces BP_Group_Member_Query and refactors bp_group_has_members() to use it

BP_Group_Member_Query extends BP_User_Query, which has a number of notable
benefits:

  • Group member queries no longer JOIN against global user tables
  • Less code duplication, since general logic like 'exclude' is handled by BP_User_Query
  • Future access to the additional parameters of BP_User_Query, such as 'type'

Using the new BP_Group_Member_Query, this changeset also changes the way that
group member queries filter by group roles (member, mod, admin). The new
group_role parameter in the bp_group_has_members() stack accepts an array of
group roles. The legacy argument 'exclude_admins_mods' is still accepted, and
translates to 'group_role' => array( 'member' ) when true. These group_role
enhancements will allow for future enhancements in the Groups Admin section of
the Dashboard, and other places where it might be useful to query for the
members of a group matching a specific role. See #4977.

Fixes #4482

Props trishasalas for early patches and feedback. Props johnjamesjacoby for
review.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/includes/testcase.php

    r7090 r7141  
    224224    }
    225225
    226     public static function add_user_to_group( $user_id, $group_id ) {
     226    public static function add_user_to_group( $user_id, $group_id, $args = array() ) {
     227        $r = wp_parse_args( $args, array(
     228            'date_modified' => bp_core_current_time(),
     229        ) );
     230
    227231        $new_member                = new BP_Groups_Member;
    228232        $new_member->group_id      = $group_id;
     
    231235        $new_member->is_admin      = 0;
    232236        $new_member->user_title    = '';
    233         $new_member->date_modified = bp_core_current_time();
     237        $new_member->date_modified = $r['date_modified'];
    234238        $new_member->is_confirmed  = 1;
    235239
Note: See TracChangeset for help on using the changeset viewer.