Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. function bp_nouveau_get_group_potential_invites( $args = array() ) {
  2.  
  3. $r = bp_parse_args( $args, array(
  4. 'group_id' => bp_get_current_group_id(),
  5. 'type' => 'alphabetical',
  6. 'per_page' => 20,
  7. 'page' => 1,
  8. 'search_terms' => false,
  9. 'member_type' => false,
  10. 'user_id' => 0,
  11. 'is_confirmed' => true,
  12. ) );
  13.  
  14. if ( empty( $r['group_id'] ) ) {
  15. return false;
  16. }
  17.  
  18.  
  19.  
  20. /*
  21. * If it's not a friend request and users can restrict invites to friends,
  22. * make sure they are not displayed in results.
  23. */
  24. if ( ! $r['user_id'] && bp_is_active( 'friends' ) && bp_is_active( 'settings' ) && ! bp_nouveau_groups_disallow_all_members_invites() ) {
  25. $r['meta_query'] = array(
  26. array(
  27. 'key' => '_bp_nouveau_restrict_invites_to_friends',
  28. 'compare' => 'NOT EXISTS',
  29. )
  30. );
  31. }
  32.  
  33. $query = new BP_Nouveau_Group_Invite_Query( $r );
  34.  
  35. $response = new stdClass();
  36.  
  37. $response->meta = array( 'total_page' => 0, 'current_page' => 0 );
  38. $response->users = array();
  39.  
  40. if ( ! empty( $query->results ) ) {
  41. $response->users = $query->results;
  42.  
  43. if ( ! empty( $r['per_page'] ) ) {
  44. $response->meta = array(
  45. 'total_page' => ceil( (int) $query->total_users / (int) $r['per_page'] ),
  46. 'page' => (int) $r['page'],
  47. );
  48. }
  49. }
  50.  
  51. return $response;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement