BP Profile Search › search results for contain
-
AuthorPost
-
liz
GuestHi
We use your plugin to search through member profiles, which use a separate profile field for names.
If someone has a middle name, the search doesn’t return results if the middle name is missing from the search terms i.e. name = John David Jones, search for ‘John Jones’ gives no results.
Any other permutation does give results – bit odd!
Search mode is set to contain, any help would be greatly appreciated!
Thanks
andrea
Plugin AuthorHi Liz,
In your case, you have to set the text search mode to is like, and search for %John%Jones% (see the Text Search Mode section here).
If you prefer to add some custom code to your site instead, please let me know and I’ll try to think of something.
liz
GuestHi Andrea
Our visitors are very unlikely to do this. If you could have a look at it and create some custom code that would be great.
Thank you so much!
andrea
Plugin AuthorHi Liz,
You can add this code to your functions.php or bp-custom.php file:
add_filter ('bps_before_search', 'change_search'); function change_search ($f) { if ($f->code == 'field_1' && $f->filter == '') { $f->filter = 'like'; $f->value = str_replace (' ', '%', $f->value); $f->values = (array)$f->value; } return $f; }I assume the names are in the field_1, otherwise you can replace field_1 with field_xyz, where xyz is the field ID.
liz
GuestHi Andrea
Got it to work, thank you for all your help.
andrea
Plugin AuthorGreat, you are welcome!
-
AuthorPost