Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =======================================================
- The code below works (it's the code from 1.6):
- =======================================================
- * @package BuddyPress Core
- */
- function bp_core_get_users( $args = '' ) {
- $defaults = array(
- 'type' => 'active', // active, newest, alphabetical, random or popular
- 'user_id' => false, // Pass a user_id to limit to only friend connections for this user
- 'exclude' => false, // Users to exclude from results
- 'search_terms' => false, // Limit to users that match these search terms
- 'meta_key' => false, // Limit to users who have this piece of usermeta
- 'meta_value' => false, // With meta_key, limit to users where usermeta matches this value
- 'include' => false, // Pass comma separated list of user_ids to limit to only these users
- 'per_page' => 20, // The number of results to return per page
- 'page' => 1, // The page to return if limiting per page
- 'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update
- );
- $params = wp_parse_args( $args, $defaults );
- extract( $params, EXTR_SKIP );
- return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras, $exclude, $meta_key, $meta_value ), $params );
- =======================================================
- This one doesn't work (it's the code from 1.7):
- =======================================================
- * @package BuddyPress Core
- */
- function bp_core_get_users( $args = '' ) {
- // Parse the user query arguments
- $params = wp_parse_args( $args, array(
- 'type' => 'active', // active, newest, alphabetical, random or popular
- 'user_id' => false, // Pass a user_id to limit to only friend connections for this user
- 'exclude' => false, // Users to exclude from results
- 'search_terms' => false, // Limit to users that match these search terms
- 'meta_key' => false, // Limit to users who have this piece of usermeta
- 'meta_value' => false, // With meta_key, limit to users where usermeta matches this value
- 'include' => false, // Pass comma separated list of user_ids to limit to only these users
- 'per_page' => 20, // The number of results to return per page
- 'page' => 1, // The page to return if limiting per page
- 'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update
- 'count_total' => 'count_query' // What kind of total user count to do, if any. 'count_query', 'sql_calc_found_rows', or false
- ) );
- // For legacy users. Use of BP_Core_User::get_users() is deprecated.
- if ( apply_filters( 'bp_use_legacy_user_query', false, __FUNCTION__, $params ) ) {
- extract( $params, EXTR_SKIP );
- $retval = BP_Core_User::get_users( $type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras, $exclude, $meta_key, $meta_value );
- // Default behavior as of BuddyPress 1.7
- } else {
- // Get users like we were asked to do...
- $users = new BP_User_Query( $params );
- // ...but reformat the results to match bp_core_get_users() behavior.
- $retval = array(
- 'users' => array_values( $users->results ),
- 'total' => $users->total_users
- );
- }
- return apply_filters( 'bp_core_get_users', $retval, $params );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement