WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

  $select_city = $_GET["name_of_city"];
  $select_city = "";

  $select_neighborhood = $_GET['name_of_neighborhood'];
  $select_neighborhood = '';

  $select_course = $_GET['name_of_course'];
  $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
share|improve this question
up vote 0 down vote accepted

put value of keys and check results.(use get_users function to query users)

            'key' => 'your_key_name_1',
            'value' => $_GET["nome_of_city"]
        'key' => 'your_key_name_2',
        'key' => 'your_key_name_3',
        'value'=> $_GET['name_of_course'],
 foreach ($users as $user) {
        echo '<li>' . $user->user_email . '</li>';

Important Link:


share|improve this answer

Ravs Hello, thanks for the reply and the help. Sorry for the delay in responding.

Well, I did exactly as you stated above, but I can not spend my arrays to function of plugin according to search.

See: I created a function my_arrays that returns three arrays, each one will be created if the user select an option select.

So I return the array to the function of plugin: return array_merge( $args3, $args4, $args5 ), Using a filter: add_filter('sul_user_query_args', 'my_arrays', 10, 3);

Being that, 'sul_user_query_args' is the filter of plugin, see how is defined in the plugin:

$args = apply_filters( 'sul_user_query_args', array_merge( $args1, $args2 ) );

The paging, the role and the total users per page are defined in $ args1 and after adding my filter the rules of $args1 does not work.

The issue is: How to apply my arrays to the filter?

I appreciate any help.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.