Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mohsinrasool/c9f60c99a06c52d06f40 to your computer and use it in GitHub Desktop.
Save mohsinrasool/c9f60c99a06c52d06f40 to your computer and use it in GitHub Desktop.
This snippet should be placed in member-loop.php within the if statement of bp_has_members check. it finds and remove the members that has the search term in the fields. It is one attempt to do that.
<?php
global $members_template;
$member_count = $members_template->member_count;
$query = $_GET['s'];
for($i=0; $i<$member_count; $i++) {
$list = bp_xprofile_get_hidden_fields_for_user($members_template->members[$i]->ID,bp_loggedin_user_id());
foreach($list as $l){
$field = new BP_XProfile_Field( $l );
$bp_field = bp_get_profile_field_data( 'field='.$field->name.'&user_id=' . $members_template->members[$i]->ID);
if(stripos($query,$bp_field) !== false) {
unset($members_template->members[$i]);
}
}
}
$members_template->member_count = count($members_template->members);
$members_template->total_member_count = count($members_template->members);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment