This topic has 8 replies, 3 voices, and was last updated 8 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

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #63520
     maelga
    Participant
    This reply has been set as private.
    #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?