I am using the Advanced Custom Field Plugin to add custom fields for the users profiles and display a list of users in the frontend of site with Simple User Listing Plugin.
I need to filter a list of users by a custom search through some options: city, neighborhood and course university.
See an example of how it is being used in this screenshot:
See the screenshot of user profile displayed on the frontend
I created a form that provides the dropdown fields to allow choice of city, neighborhood and choose one of courses, but filtering does not work.
Instead of search a single user, as what is provided by the plugin, I need to display multiple users based on the search terms.
My question is: How to pass an array of values to search for users and return to the list?
Here's an example of the code that I added to search by the city, the neighborhood and the course, but the search does not work. I do not know much about PHP.
if ($_GET["FormOfSearch"]){ // if search form is submitted
if(isset($_GET["nome_of_city"]))
{
$select_city = $_GET["name_of_city"];
}else{
$select_city = "";
}
if(isset($_GET['name_of_neighborhood']))
{
$select_neighborhood = $_GET['name_of_neighborhood'];
}else{
$select_neighborhood = '';
}
if(isset($_GET['name_of_course'])){
$select_course = $_GET['name_of_course'];
}else{
$select_course = '';
}
$list_of_id = "SELECT user_id FROM $wpdb->usermeta WHERE (meta_value = '$select_city') AND user_id IN (SELECT user_id FROM $wpdb->usermeta WHERE (meta_value= '$select_neighborhood')) AND user_id IN (SELECT user_id FROM $wpdb->usermeta WHERE (meta_value = '$select_course'))";
// Below, the array provided by plugin, I add the list of ID searched
// Generate the query based on search field
$args2 = array(
'include' => '*' . $list_of_id . '*',
'number' => $number,
'orderby' => $orderby,
'order' => $order
);