Changeset 12663
- Timestamp:
- 06/10/2020 02:09:59 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-functions.php
r12657 r12663 79 79 * 80 80 * @since 1.2.0 81 * @since 7.0.0 Added `xprofile_query` parameter. 81 82 * 82 83 * @param array|string $args { … … 97 98 * @type int $page Page of results. Default: 1. 98 99 * @type bool $populate_extras Fetch optional extras. Default: true. 100 * @type array $xprofile_query Filter results by xprofile data. Requires the xprofile 101 * component. See {@see BP_XProfile_Query} for details. 99 102 * @type string|bool $count_total How to do total user count. Default: 'count_query'. 100 103 * } … … 118 121 'page' => 1, // The page to return if limiting per page. 119 122 'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update. 123 'xprofile_query' => false, 120 124 'count_total' => 'count_query' // What kind of total user count to do, if any. 'count_query', 'sql_calc_found_rows', or false. 121 125 ), 'core_get_users' ); -
trunk/src/bp-members/bp-members-template.php
r12647 r12663 283 283 * 284 284 * @since 1.2.0 285 * @since 7.0.0 Added `xprofile_query` parameter. 285 286 * 286 287 * @global object $members_template {@link BP_Members_Template} … … 326 327 * @type mixed $meta_value When used with meta_key, limits results by the a matching 327 328 * usermeta value. Default: false. 329 * @type array $xprofile_query Filter results by xprofile data. Requires the xprofile 330 * component. See {@see BP_XProfile_Query} for details. 328 331 * @type bool $populate_extras Whether to fetch optional data, such as friend counts. 329 332 * Default: true. … … 379 382 'meta_value' => false, // Only return users where the usermeta value matches. Requires meta_key. 380 383 384 'xprofile_query' => false, 381 385 'populate_extras' => true // Fetch usermeta? Friend count, last active etc. 382 386 ), 'has_members' ); … … 412 416 $r['member_type'], 413 417 $r['member_type__in'], 414 $r['member_type__not_in'] 418 $r['member_type__not_in'], 419 $r['xprofile_query'] 415 420 ); 416 421 -
trunk/src/bp-members/classes/class-bp-core-members-template.php
r10711 r12663 111 111 * 112 112 * @since 1.5.0 113 * @since 7.0.0 Added $xprofile_query parameter. 113 114 * 114 115 * @see BP_User_Query for an in-depth description of parameters. … … 131 132 * @param array|string $member_type__not_in Array or comma-separated string of member types to exclude 132 133 * from results. 133 */ 134 function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage', $member_type = '', $member_type__in = '', $member_type__not_in = '' ) { 134 * @param array $xprofile_query Filter results by xprofile data. Requires the xprofile 135 * component. See {@see BP_XProfile_Query} for details. 136 */ 137 function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage', $member_type = '', $member_type__in = '', $member_type__not_in = '', $xprofile_query = false ) { 135 138 136 139 $this->pag_arg = sanitize_key( $page_arg ); … … 139 142 $this->type = $type; 140 143 141 if ( ! empty( $_REQUEST['letter'] ) )144 if ( ! empty( $_REQUEST['letter'] ) ) { 142 145 $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras, $exclude ); 143 else 144 $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras, 'exclude' => $exclude, 'meta_key' => $meta_key, 'meta_value' => $meta_value, 'member_type' => $member_type, 'member_type__in' => $member_type__in, 'member_type__not_in' => $member_type__not_in ) ); 146 } else { 147 $this->members = bp_core_get_users( 148 array( 149 'type' => $this->type, 150 'per_page' => $this->pag_num, 151 'page' => $this->pag_page, 152 'user_id' => $user_id, 153 'include' => $include, 154 'search_terms' => $search_terms, 155 'populate_extras' => $populate_extras, 156 'exclude' => $exclude, 157 'meta_key' => $meta_key, 158 'meta_value' => $meta_value, 159 'member_type' => $member_type, 160 'member_type__in' => $member_type__in, 161 'member_type__not_in' => $member_type__not_in, 162 'xprofile_query' => $xprofile_query, 163 ) 164 ); 165 } 145 166 146 167 if ( !$max || $max >= (int) $this->members['total'] ) -
trunk/tests/phpunit/testcases/members/template.php
r12459 r12663 185 185 $GLOBALS['members_template'] = $old_members_template; 186 186 } 187 188 /** 189 * @group bp_has_members 190 * @ticket BP8309 191 */ 192 public function test_bp_has_members_xprofile_query() { 193 $group_id = self::factory()->xprofile_group->create(); 194 $field_id = self::factory()->xprofile_field->create( array( 195 'field_group_id' => $group_id, 196 'type' => 'textbox', 197 ) ); 198 $users = self::factory()->user->create_many( 2 ); 199 200 xprofile_set_field_data( $field_id, $users[0], 'foo' ); 201 xprofile_set_field_data( $field_id, $users[1], 'bar' ); 202 203 global $members_template; 204 $old_members_template = $members_template; 205 206 $args = array( 207 'xprofile_query' => array( 208 array( 209 'field' => $field_id, 210 'value' => 'foo', 211 ), 212 ), 213 ); 214 215 bp_has_members( $args ); 216 217 $members = is_array( $members_template->members ) ? array_values( $members_template->members ) : array(); 218 $member_ids = wp_list_pluck( $members, 'ID' ); 219 $this->assertEqualSets( array( $users[0] ), $member_ids ); 220 221 $GLOBALS['members_template'] = $old_members_template; 222 } 223 187 224 188 225 /**
Note: See TracChangeset
for help on using the changeset viewer.