wordpress get_users with multile roles?

Hi
i am creating a team members section in my about page. i need to get all the users with the roles of editors and administrators. i have tried to pass an array to the args role but it only accept a string.
and by the way, i also need more meta info regarding those who will return, i also cannot pass that.

so this is what i have:
$args = array(
	'blog_id'      => $GLOBALS['blog_id'],
	'role'         => "",
	'meta_key'     => '',
	'meta_value'   => '',
	'meta_compare' => '',
	'meta_query'   => array(),
	'date_query'   => array(),        
	'include'      => array(),
	'exclude'      => array(),
	'orderby'      => 'login',
	'order'        => 'ASC',
	'offset'       => '',
	'search'       => '',
	'number'       => '',
	'count_total'  => false,
	'fields'       => 'all',
	'who'          => ''
 ); 

$users = get_users( $args );

Open in new window


so i tried meta value and role. but it doesn't work.

what am i missing here?

best regards
LVL 1
derridaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

derridaAuthor Commented:
anyone?
0
derridaAuthor Commented:
ok managed to find how to do it. so hope it will help others.
it is very stupid that you can only pass one role and not an array. so this is what you have to do:
make several queries for each role and then merge them. not elegant at all.

$editor_query = new WP_User_Query(
    array(
        'role'  =>  'editor',
        'orderby' => 'registered', 
        'order' => 'ASC',
        'fields' => 'all_with_meta'
    )
);
$editors = $editor_query->get_results();


$administrator_query = new WP_User_Query(
    array(
        'role'  =>  'administrator',
/*        'exclude' => array(),*/
        'orderby' => 'registered', 
        'order' => 'ASC',
        'fields' => 'all'
    )
);
$admins = $administrator_query->get_results();

// store them all as users
$users = array_merge( $admins, $editors );

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.