-
Author
Tagged: search
-
June 16, 2015 at 09:15 #63075
maelga
ParticipantHi 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?June 17, 2015 at 16:09 #63465Laura
ModeratorHello, 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 solutionJune 17, 2015 at 19:18 #63520maelga
ParticipantHi,
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 futureLet me know if you need something else.
Thanks for your supportJune 21, 2015 at 07:55 #64157Andrei
ModeratorHi @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 solutionJune 23, 2015 at 14:58 #64457Andrei
ModeratorHi,
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.
CheersHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 23, 2015 at 16:28 #64493maelga
ParticipantHi 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=8The 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?
June 23, 2015 at 16:30 #64495maelga
ParticipantSame 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). ')';June 23, 2015 at 17:41 #64524Andrei
ModeratorI 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 -
AuthorPosts
You must be logged in to reply to this topic.