I had not thought about this when I created Nobody visibility… You’re right, but I believe I can’t solve it.
I’ve been searching in buddypress code where they do the search and there is no filter to modify the query… So the only way I think will be modify buddypress plugin…
If you want to modify it inside buddypress, the file is:buddypress/bp-core/bp-core-classes.php. Line 364.
/** Search Terms ******************************************************/
// 'search_terms' searches the xprofile fields
// To avoid global joins, do a separate query
// @todo remove need for bp_is_active() check
if ( false !== $search_terms && bp_is_active( 'xprofile' ) ) {
$search_terms_clean = mysql_real_escape_string( mysql_real_escape_string( $search_terms ) );
$search_terms_clean = like_escape( $search_terms_clean );
$found_user_ids_query = "SELECT user_id FROM {$bp->profile->table_name_data} WHERE value LIKE '%" . $search_terms_clean . "%'";
$found_user_ids = $wpdb->get_col( $found_user_ids_query );
if ( ! empty( $found_user_ids ) ) {
$sql['where'][] = "u.{$this->uid_name} IN (" . implode( ',', wp_parse_id_list( $found_user_ids ) ) . ")";
} else {
$sql['where'][] = $this->no_results['where'];
}
}
You need to change the query to avoid searching in the fields with nobody visibility.