I have an array like
$user_id = [1,10,15,8,6];
and I want to get a list of this user using the get_users
method.
$args = array(
'role' => 'any',
'orderby' => 'user_nicename',
'order' => 'ASC'
);
$users = get_users($args);
but I don’t know how to pass an array of user ids to get only those users. I don’t need to get all users, I just need user list which has ids 1,10,15,8,6
2
Answers
You can try this, it’s working perfectly from my side.
Note: get got all user information as array formate.
Updated
If you don’t want to loop you can use include inside query like this:
Hii parth I just do a pretty solution.
no for loop no more queries enjoy.
also check the WordPress documents below that might be help you in some of more queries.
https://developer.wordpress.org/reference/classes/wp_user_query/