Guest User

Untitled

a guest
Oct 22nd, 2018
191
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter ('bp_ajax_querystring', 'modify_members_loop', 20, 2);
  2. function modify_members_loop ($qs=false, $object=false)
  3. {
  4. global $wpdb;
  5. if ($object != 'members') return $qs;
  6.  
  7. // figure out if the logged-in user is male or female
  8. $gender = xprofile_get_field_data (9, bp_loggedin_user_id ());
  9.  
  10. if ($gender == 'Male')
  11. $query = "SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 9 AND value = 'Female'";
  12. else
  13. $query = "SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 9 AND value = 'Male'";
  14.  
  15. $custom_ids = $wpdb->get_col ($query);
  16.  
  17. $args = wp_parse_args ($qs);
  18. $args['include'] = implode (',', $custom_ids);
  19. $qs = build_query ($args);
  20.  
  21. return $qs;
  22. }
RAW Paste Data