users – WP_User_Query combining role and ids

Question

I would like to get array of all authors (except few), add several admins to it (by ids) and order the array by user names. But I can’t find the way how to make it in one WP_User_Query.

When I called those two subqueries separately and put the results together by array_merge(), it was ok, but I need to order them by name, which was not possible in that way…

So right now I am trying something like this, but it gets me all the users. What I am doing wrong?

$args = array(
    'orderby'  => 'display_name',
    'order'    => 'ASC',
    array(
        'relation' => 'OR',
        array(
            'role' =>   'author',
            'exclude' => array(36, 41)
        ),
        array(
            'include' => array(23, 45),
        )
    )
);

0
Tomas Korinek 5 months 2021-06-19T14:48:21-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse