Skip to:
Content

BuddyPress.org

Ticket #7573: 7573.01.patch

File 7573.01.patch, 5.6 KB (added by r-a-y, 3 years ago)
  • src/bp-groups/bp-groups-functions.php

     
    638638 * returning true.
    639639 *
    640640 * @since 1.0.0
     641 * @since 3.0.0 $group_id now supports multiple values. Only works if legacy query is not
     642 *              in use.
    641643 *
    642644 * @param array $args {
    643645 *     An array of optional arguments.
    644  *     @type int      $group_id     ID of the group whose members are being queried.
    645  *                                  Default: current group ID.
    646  *     @type int      $page         Page of results to be queried. Default: 1.
    647  *     @type int      $per_page     Number of items to return per page of results.
    648  *                                  Default: 20.
    649  *     @type int      $max          Optional. Max number of items to return.
    650  *     @type array    $exclude      Optional. Array of user IDs to exclude.
    651  *     @type bool|int $value        True (or 1) to exclude admins and mods from results.
    652  *                                  Default: 1.
    653  *     @type bool|int $value        True (or 1) to exclude banned users from results.
    654  *                                  Default: 1.
    655  *     @type array    $group_role   Optional. Array of group roles to include.
    656  *     @type string   $search_terms Optional. Filter results by a search string.
    657  *     @type string   $type         Optional. Sort the order of results. 'last_joined',
    658  *                                  'first_joined', or any of the $type params available
    659  *                                  in {@link BP_User_Query}. Default: 'last_joined'.
     646 *     @type int|array|string $group_id            ID of the group to limit results to. Also accepts multiple values
     647 *                                                 either as an array or as a comma-delimited string.
     648 *     @type int              $page                Page of results to be queried. Default: 1.
     649 *     @type int              $per_page            Number of items to return per page of results. Default: 20.
     650 *     @type int              $max                 Optional. Max number of items to return.
     651 *     @type array            $exclude             Optional. Array of user IDs to exclude.
     652 *     @type bool|int         $exclude_admins_mods True (or 1) to exclude admins and mods from results. Default: 1.
     653 *     @type bool|int         $exclude_banned      True (or 1) to exclude banned users from results. Default: 1.
     654 *     @type array            $group_role          Optional. Array of group roles to include.
     655 *     @type string           $search_terms        Optional. Filter results by a search string.
     656 *     @type string           $type                Optional. Sort the order of results. 'last_joined', 'first_joined', or
     657 *                                                 any of the $type params available in {@link BP_User_Query}. Default:
     658 *                                                 'last_joined'.
    660659 * }
    661660 * @return false|array Multi-d array of 'members' list and 'count'.
    662661 */
  • src/bp-groups/classes/class-bp-group-member-query.php

     
    2424 *   inviter_id = 0 (and invite_sent = 0).
    2525 *
    2626 * @since 1.8.0
     27 * @since 3.0.0 $group_id now supports multiple values.
    2728 *
    2829 * @param array $args  {
    2930 *     Array of arguments. Accepts all arguments from
    3031 *     {@link BP_User_Query}, with the following additions:
    3132 *
    32  *     @type int    $group_id     ID of the group to limit results to.
    33  *     @type array  $group_role   Array of group roles to match ('member',
    34  *                                'mod', 'admin', 'banned').
    35  *                                Default: array( 'member' ).
    36  *     @type bool   $is_confirmed Whether to limit to confirmed members.
    37  *                                Default: true.
    38  *     @type string $type         Sort order. Accepts any value supported by
    39  *                                {@link BP_User_Query}, in addition to 'last_joined'
    40  *                                and 'first_joined'. Default: 'last_joined'.
     33 *     @type int|array|string $group_id     ID of the group to limit results to. Also accepts multiple values
     34 *                                          either as an array or as a comma-delimited string.
     35 *     @type array            $group_role   Array of group roles to match ('member', 'mod', 'admin', 'banned').
     36 *                                          Default: array( 'member' ).
     37 *     @type bool             $is_confirmed Whether to limit to confirmed members. Default: true.
     38 *     @type string           $type         Sort order. Accepts any value supported by {@link BP_User_Query}, in
     39 *                                          addition to 'last_joined' and 'first_joined'. Default: 'last_joined'.
    4140 * }
    4241 */
    4342class BP_Group_Member_Query extends BP_User_Query {
     
    137136                /* WHERE clauses *****************************************************/
    138137
    139138                // Group id.
    140                 $sql['where'][] = $wpdb->prepare( "group_id = %d", $this->query_vars['group_id'] );
     139                $group_ids = wp_parse_id_list( $this->query_vars['group_id'] );
     140                if ( ! empty( $group_ids ) ) {
     141                        $group_ids_sql = implode( ',', $group_ids );
     142                        $group_ids_sql = "group_id IN ({$group_ids_sql})";
     143                } else {
     144                        $group_ids_sql = $wpdb->prepare( "group_id = %d", $this->query_vars['group_id'] );
     145                }
     146                $sql['where'][] = $group_ids_sql;
    141147
    142148                // If is_confirmed.
    143149                $is_confirmed = ! empty( $this->query_vars['is_confirmed'] ) ? 1 : 0;