Title: Exclude Users using bp_ajax_querystring
Last modified: March 6, 2017

---

# Exclude Users using bp_ajax_querystring

 *  Resolved [sitesforchrist](https://wordpress.org/support/users/sitesforchrist/)
 * (@sitesforchrist)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/exclude-users-using-bp_ajax_querystring/)
 * We are using bp_ajax_querystring to exclude certain users from our default search
   results. But it doesn’t appear to be working with the global search plugin. Is
   it possible to hook into this function (or another one) within the global search
   plugin in order to achieve the same results?
 * Thanks!
    Sarah

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [sitesforchrist](https://wordpress.org/support/users/sitesforchrist/)
 * (@sitesforchrist)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/exclude-users-using-bp_ajax_querystring/#post-8881957)
 * Nevermind, I was able to figure out how to do this using the following code in
   case it helps someone else. It’s kind of patch-y, but it works:
 *     ```
       add_filter('BBoss_Global_Search_Members_sql','exclude_users_global_search');
       function exclude_users_global_search($sql){
       	$exclude = '1,10,6'; //comma separated ids of users whom you want to exclude
   
       	$sql = str_replace('u.id IN', 'u.ID NOT IN (' . $exclude. ') AND u.ID IN', $sql);
   
       	return $sql;
       }
       ```
   
 *  Plugin Author [BuddyBoss](https://wordpress.org/support/users/buddyboss/)
 * (@buddyboss)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/exclude-users-using-bp_ajax_querystring/#post-8882377)
 * Cool, Glad you figure out yourself.
 *  [catonezillion](https://wordpress.org/support/users/catonezillion/)
 * (@catonezillion)
 * [9 years ago](https://wordpress.org/support/topic/exclude-users-using-bp_ajax_querystring/#post-9150441)
 * Hi,
 * I’d like to try this- can you let me know what file to add it to?
 * Thanks
 *  Plugin Author [BuddyBoss](https://wordpress.org/support/users/buddyboss/)
 * (@buddyboss)
 * [9 years ago](https://wordpress.org/support/topic/exclude-users-using-bp_ajax_querystring/#post-9154895)
 * [@catonezillion](https://wordpress.org/support/users/catonezillion/),
    You can
   add above codes inside your child theme functions.php
 *  [catonezillion](https://wordpress.org/support/users/catonezillion/)
 * (@catonezillion)
 * [9 years ago](https://wordpress.org/support/topic/exclude-users-using-bp_ajax_querystring/#post-9162076)
 * Thanks! Now that I think of it- it may be better to exclude by member type or
   role- can that be done?
 * Cathy

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Exclude Users using bp_ajax_querystring’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/buddypress-global-search_e2623d.svg)
 * [BuddyPress Global Search](https://wordpress.org/plugins/buddypress-global-search/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/buddypress-global-search/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/buddypress-global-search/)
 * [Active Topics](https://wordpress.org/support/plugin/buddypress-global-search/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/buddypress-global-search/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/buddypress-global-search/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [catonezillion](https://wordpress.org/support/users/catonezillion/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/exclude-users-using-bp_ajax_querystring/#post-9162076)
 * Status: resolved