Changeset 8973
- Timestamp:
- 09/02/2014 06:40:37 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-template.php
r8931 r8973 430 430 global $members_template; 431 431 432 /*** 433 * Set the defaults based on the current page. Any of these will be overridden 434 * if arguments are directly passed into the loop. Custom plugins should always 435 * pass their parameters directly to the loop. 436 */ 437 $type = 'active'; 438 $user_id = 0; 439 $page = 1; 440 $search_terms = null; 432 // Default user ID 433 $user_id = 0; 441 434 442 435 // User filtering … … 446 439 447 440 // type: active ( default ) | random | newest | popular | online | alphabetical 448 $ defaults =array(449 'type' => $type,450 'page' => $page,441 $r = bp_parse_args( $args, array( 442 'type' => 'active', 443 'page' => 1, 451 444 'per_page' => 20, 452 445 'max' => false, 453 446 454 'page_arg' => 'upage', // See https://buddypress.trac.wordpress.org/ticket/3679 455 456 'include' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users 457 'exclude' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users 458 459 'user_id' => $user_id, // Pass a user_id to only show friends of this user 460 'search_terms' => $search_terms, // Pass search_terms to filter users by their profile data 461 462 'meta_key' => false, // Only return users with this usermeta 463 'meta_value' => false, // Only return users where the usermeta value matches. Requires meta_key 464 465 'populate_extras' => true // Fetch usermeta? Friend count, last active etc. 447 'page_arg' => 'upage', // See https://buddypress.trac.wordpress.org/ticket/3679 448 449 'include' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users 450 'exclude' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users 451 452 'user_id' => $user_id, // Pass a user_id to only show friends of this user 453 'search_terms' => null, // Pass search_terms to filter users by their profile data 454 455 'meta_key' => false, // Only return users with this usermeta 456 'meta_value' => false, // Only return users where the usermeta value matches. Requires meta_key 457 458 'populate_extras' => true // Fetch usermeta? Friend count, last active etc. 459 ), 'has_members' ); 460 461 // Pass a filter if ?s= is set. 462 if ( is_null( $r['search_terms'] ) ) { 463 if ( !empty( $_REQUEST['s'] ) ) { 464 $r['search_terms'] = $_REQUEST['s']; 465 } else { 466 $r['search_terms'] = false; 467 } 468 } 469 470 // Set per_page to max if max is larger than per_page 471 if ( !empty( $r['max'] ) && ( $r['per_page'] > $r['max'] ) ) { 472 $r['per_page'] = $r['max']; 473 } 474 475 // Query for members and populate $members_template global 476 $members_template = new BP_Core_Members_Template( 477 $r['type'], 478 $r['page'], 479 $r['per_page'], 480 $r['max'], 481 $r['user_id'], 482 $r['search_terms'], 483 $r['include'], 484 $r['populate_extras'], 485 $r['exclude'], 486 $r['meta_key'], 487 $r['meta_value'], 488 $r['page_arg'] 466 489 ); 467 490 468 $r = bp_parse_args( $args, $defaults, 'has_members' );469 extract( $r );470 471 // Pass a filter if ?s= is set.472 if ( is_null( $search_terms ) ) {473 if ( !empty( $_REQUEST['s'] ) )474 $search_terms = $_REQUEST['s'];475 else476 $search_terms = false;477 }478 479 // Set per_page to max if max is larger than per_page480 if ( !empty( $max ) && ( $per_page > $max ) )481 $per_page = $max;482 483 $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras, $exclude, $meta_key, $meta_value, $page_arg );484 491 return apply_filters( 'bp_has_members', $members_template->has_members(), $members_template ); 485 492 }
Note: See TracChangeset
for help on using the changeset viewer.