I am trying to create a script that will search members from profile values. I have no problem doing this with one field however, when I try to add more search terms the code displays only the last term added in the code. Please see the code:
<?php if (( bp_has_members( "search_terms={$_POST['category']}")) && ( bp_has_members( "search_terms={$_POST['area_members']}"))) : ?>
<?php while ( bp_members() ) : bp_the_member(); ?>
....
<?php endwhile; ?>
<?php endif; ?>
When I do this the result its just a search of the last term ['area_members'], the term ['category'] its not initiated.
Any Idea why and how I can achieve this?
The second call ( or last call ) to bp_has_members
is the one used in the while loop. To search on multiple terms, put a space between each term. The search is based on ‘AND’, not ‘OR’.
Try:
$search_terms = $_POST['category'] . ' ' . $_POST['area_members'];
if ( bp_has_members( "search_terms={$search_terms}")) :