match any for multiple fields in form

BP Profile Search › match any for multiple fields in form

  • Author
    Post
  • #9695 Reply
    Josh Page
    Guest

    Hey Andrea,

    First off I’d like to just say thankyou. You help me with a previous issue of hiding unfilled fields within a checkbox search form.

    I have another question for you. I have 12 bp fields that all contain numerous values as checkboxes. I’ve built a form with these 12 fields and the ‘match any’ search mode. Within each individual field the ‘match any’ option works great. But if the searching user checks boxes in different fields the ‘match any’ option doesnt work. Unless the profile contains both the field values being searched it wont show up.

    Example of what I’d like to achieve:
    Searchable fields
    Dogs
    – Black dog
    – White dog
    – Red dog

    Cat
    – Black cat
    – White cat
    – Red cat

    User searches for Black dog, and Red cat (checkboxes)
    All profiles with either Black dog **OR** Red cat are in results as well as profiles with Black dog **AND** Red cat.

    I hope this makes sense and really appreciate any help you can give me in finding a solution.

    Thanks in advance
    Josh Page

    #9696 Reply
    andrea
    Plugin Author

    Hello Josh,

    By default, BP Profile Search finds results that match all the search fields.

    If you wish to find results that match at least one of the search fields, you can add this code to your bp-custom.php file:

    add_filter ('bps_match_all', '__return_false');

    and you should get the search results as in your example.

    Please let me know if that works for you!

    #9697 Reply
    Josh Page
    Guest

    Andrea! Your the best. Thanks so much.

    #9698 Reply
    andrea
    Plugin Author

    Great, you are welcome!

Reply to: match any for multiple fields in form
My Information