BP Profile Search › Searching containing words?
-
AuthorPost
-
Oh Happy
GuestWhen my users sign up on my page they can choose to be:
-Seller
-Buyer or
-Both Seller and buyer.
That I have set up as a dropdown select box under the profile fields.But when I go to the profile search I can only search for each of the three profile types seperately. I would like to ensure that if I search for “seller” all the members who see them self as “both seller and buyer” should also occur in the search results.
How do I do that?
Is there a way to ensure that the profile search somehow search for the words that is selected in the dropdown box?andrea
Plugin AuthorHi there,
You could change the search mode of your field from ‘is’ to ‘is one of’. This way the search field will appear as three checkboxes and your users could check one or more of them.
The other options you suggest are not feasible with the current BP Profile Search, but I hope the above is an acceptable workaround.
Oh Happy
GuestHi Andrea
Well, I dont really think that the checkboxes are a feasiable solution because then the layout/styling of the search fields changes so that e.g. the horizontal form gets messy to look at. That’s why I prefer the dropdown selection.
So could you help with some code for the function child that could help that the searching looks for both words?
andrea
Plugin AuthorTry adding this code to your bp-custom.php file:
add_filter ('bps_field_sql', 'change_query', 10, 2); function change_query ($sql, $f) { if ($f->id == 9) $sql['where']['text_is'] = bps_sql_expression ("value LIKE %s", $f->value, true); return $sql; }Replace 9 with the field ID of your buyer/seller profile field.
-
AuthorPost