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'm able to list users by a single role only. When I try and add an array to the code below I just get a list of all authors. I'm sure that it is something straight forward that I'm missing.




            $roles = array('guest-teacher', 'president', 'core-faculty');

   $args  = array(
     'meta_key' => 'last_name',
     'role'     => $roles

    $wp_user_query = new WP_User_Query($args);
    $wp_user_query->query_orderby = str_replace( 'user_login', 'lsjs_usermeta.meta_value', $wp_user_query->query_orderby );

    $authors = $wp_user_query->get_results();

    // Check for results;
    if (!empty($authors))
        echo '<ul class="permanent">';
        // loop trough each author
        foreach ($authors as $author)
            // get all the user's data
            $author_info = get_userdata($author->ID);
            $url = get_author_posts_url($author->ID);  


        <h3><a href="<?php echo $url; ?>"><?php echo $author_info->last_name; ?></a></h3>

        echo '</ul>';
    } else {

share|improve this question
up vote 2 down vote accepted

Unfortunately, you cannot pass an Array of User Roles to WP_User_Query. The role argument only accepts a String, which is then cleared by a trim command.

See user.php on Line 495, where prepare handles the Query for the Constructor after parsing the $args.

share|improve this answer
Thanks. So it seems like roles also can't be excluded. – Josh Feb 26 '13 at 12:40
Hm, I am not sure about that - try -role, but I think it won't work. – fischi Feb 26 '13 at 12:48

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.