Advertisement
Guest User

Untitled

a guest
Apr 16th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. =======================================================
  2. The code below works (it's the code from 1.6):
  3. =======================================================
  4. * @package BuddyPress Core
  5. */
  6. function bp_core_get_users( $args = '' ) {
  7.  
  8. $defaults = array(
  9. 'type' => 'active', // active, newest, alphabetical, random or popular
  10. 'user_id' => false, // Pass a user_id to limit to only friend connections for this user
  11. 'exclude' => false, // Users to exclude from results
  12. 'search_terms' => false, // Limit to users that match these search terms
  13. 'meta_key' => false, // Limit to users who have this piece of usermeta
  14. 'meta_value' => false, // With meta_key, limit to users where usermeta matches this value
  15.  
  16. 'include' => false, // Pass comma separated list of user_ids to limit to only these users
  17. 'per_page' => 20, // The number of results to return per page
  18. 'page' => 1, // The page to return if limiting per page
  19. 'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update
  20. );
  21.  
  22. $params = wp_parse_args( $args, $defaults );
  23. extract( $params, EXTR_SKIP );
  24.  
  25. 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 );
  26.  
  27. =======================================================
  28. This one doesn't work (it's the code from 1.7):
  29. =======================================================
  30.  
  31. * @package BuddyPress Core
  32. */
  33. function bp_core_get_users( $args = '' ) {
  34.  
  35. // Parse the user query arguments
  36. $params = wp_parse_args( $args, array(
  37. 'type' => 'active', // active, newest, alphabetical, random or popular
  38. 'user_id' => false, // Pass a user_id to limit to only friend connections for this user
  39. 'exclude' => false, // Users to exclude from results
  40. 'search_terms' => false, // Limit to users that match these search terms
  41. 'meta_key' => false, // Limit to users who have this piece of usermeta
  42. 'meta_value' => false, // With meta_key, limit to users where usermeta matches this value
  43. 'include' => false, // Pass comma separated list of user_ids to limit to only these users
  44. 'per_page' => 20, // The number of results to return per page
  45. 'page' => 1, // The page to return if limiting per page
  46. 'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update
  47. 'count_total' => 'count_query' // What kind of total user count to do, if any. 'count_query', 'sql_calc_found_rows', or false
  48. ) );
  49.  
  50. // For legacy users. Use of BP_Core_User::get_users() is deprecated.
  51. if ( apply_filters( 'bp_use_legacy_user_query', false, __FUNCTION__, $params ) ) {
  52. extract( $params, EXTR_SKIP );
  53. $retval = BP_Core_User::get_users( $type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras, $exclude, $meta_key, $meta_value );
  54.  
  55. // Default behavior as of BuddyPress 1.7
  56. } else {
  57.  
  58. // Get users like we were asked to do...
  59. $users = new BP_User_Query( $params );
  60.  
  61. // ...but reformat the results to match bp_core_get_users() behavior.
  62. $retval = array(
  63. 'users' => array_values( $users->results ),
  64. 'total' => $users->total_users
  65. );
  66. }
  67.  
  68. return apply_filters( 'bp_core_get_users', $retval, $params );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement