1

I am trying to get users that are either administrator, editor or author as their role from the wordpress database

$args = array('orderby' => 'post_count', 'order' => 'DESC','number' => 20, 'role' => 'administrator' );

That gets the administrator so i thought this would work

$args = array('orderby' => 'post_count', 'order' => 'DESC','number' => 20, 'role' => array('administrator','editor','author') );

It returned no results. ?

1
  • var_export would be preferable to print_r, as it results in a PHP-parseable (hence, more useable) representation. Commented Dec 20, 2011 at 19:12

1 Answer 1

1

You cannot pass multiple roles in $args, you must call get_users once for each role

From the documentation:

  • role - Limit the returned authors to the role specified.

Note that "role" is singular in the parameter description. Call get_users once for each role then merge the arrays together of the results

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.