Searching containing words?

Home Forums BP Profile Search Forum Searching containing words?

This topic contains 3 replies, has 2 voices, and was last updated by  andrea 2 months, 1 week ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #9899 Reply

    Oh Happy

    When 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?

    #9901 Reply

    andrea
    Keymaster

    Hi 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.

    #9907 Reply

    Oh Happy

    Hi 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?

    #9909 Reply

    andrea
    Keymaster

    Try 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.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Searching containing words?
Your information: