This topic has 8 replies, 3 voices, and was last updated 10 years by Andrei.

  • Author

    Tagged: 

  • #63075
     maelga
    Participant

    Hi Laura,

    I have customised my horizontal search as an advanced search form and everything looks neat.

    However 1 of the field type is checkbox with 10 options to choose from.
    When running the search, the results returned are profiles that match any of the options checked (i.e. OR search).
    For my site, it must be a AND search, e.g. only profiles matching all checkboxes should be returned.

    How to edit the kleo-bp-search.php to achieve this?

    I got a way to do it with BP Profile Search plugin (https://wordpress.org/support/topic/checkbox-search-for-both-rather-than-or) but BP Profile Search does not work with Sweetdate (see my previous thread: https://archived.seventhqueen.com/forums/topic/conflict-with-bp-profile-search-plugin).

    Implementing the BP Profile Search way into kleo-bp-search.php does not work.
    Looking at both codes, it should be very similar though.

    Any idea how to make it work in kleo-bp-search.php?
    Alternatively, back to my previous thread: How to make BP Profile Search work with Sweetdate?

    #63465
     Laura
    Moderator

    Hello, thank you very much for contacting us , will assign the ticket to a higher support lever who can help and advise you in your query.
    It would be good to have you credentials to facilitate our work.
    Thanks! 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #63520
     maelga
    Participant

    Hi,

    You can play around with the Advanced search form at http://homestic.co/members/
    The 10 checkboxes are obviously under “Family needs”.

    I have 3 dummy users (helper1, helper2, helper3) to search from.
    -Only Helper1 should be returned for kids care (0-1, 1-3, 3-6, 6-12)
    -Only Helper2 should be returned for elderly/invalid/pet care
    -All 3 helpers should be returned for housekeeping/cooking/shopping.
    To have full access to all their profile fields, you can login with username: employer3 (password: maelga)

    If you want you can also try BP Profile Search plugin form at http://homestic.co/advanced-search-bps/
    Whatever search criteria used, all members are returned. That’s the compatibility issue with Sweetdate, independent from my child theme.

    Hopefully you are able to come up with 2 fixes for kleo-bp-search.php:
    -An immediate fix to use the neat advanced search form in members directory.
    -Another fix so I can use BP Search plugin sometime in the future

    Let me know if you need something else.
    Thanks for your support

    #64154
     maelga
    Participant

    Hello. Any update on this?

    #64157
     Andrei
    Moderator

    Hi @maelga, I will gonna give a look into this and come with a reply as soon as possible.
    Thank you for your patience.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #64457
     Andrei
    Moderator

    Hi,

    I have given a look into this and it seems the query is OR for multiselects/checkboxes.
    You can change this from the “wp-content/themes/sweetdate/custom_buddypress/kleo-bp-search.php” file at line: 671.

    Let me know if it worked.
    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #64493
     maelga
    Participant

    Hi Andrei,

    Changing $sql .= ' AND ('. implode (' OR ', $like). ')'; to $sql .= ' AND ('. implode (' AND ', $like). ')'; does not work.

    You can have a head start by spending 30 sec reading this brief thread:
    https://wordpress.org/support/topic/checkbox-search-for-both-rather-than-or?replies=8

    The solution was to replace `$like[] = $wpdb->prepare (“value = %s OR value LIKE %s”, $value, $escaped);
    }
    $sql .= ‘AND (‘. implode (‘ OR ‘, $like). ‘)’;with$like[] = $wpdb->prepare (“value LIKE %s”, $escaped);
    }
    $sql .= ‘AND (‘. implode (‘ AND ‘, $like). ‘)’;`

    I have tested it with both BP Profile Search and kleo-search.php. It works with BP Profile Search but unfortunately not with kleo-search.php

    Do you have any suggestion?

    #64495
     maelga
    Participant

    Same code as above, just making it clearer:

    COPY CODE
    $like[] = $wpdb->prepare ("value = %s OR value LIKE %s", $value, $escaped);
    }
    $sql .= 'AND ('. implode (' OR ', $like). ')';

    with

    COPY CODE
    $like[] = $wpdb->prepare ("value LIKE %s", $escaped);
    }
    $sql .= 'AND ('. implode (' AND ', $like). ')';
    #64524
     Andrei
    Moderator

    I have just tested this scenario out to be sure it works, please revert your kleo-bp-search.php file to the stock one, and taking into consideration that you have the last version of the theme, go to line 671 and replace:

    COPY CODE
    $sql .= ' AND ('. implode (' OR ', $like). ')';

    with

    COPY CODE
    $sql .= ' AND ('. implode (' AND ', $like). ')';

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?