I’m not sure where the problem lies, but the code below just doesn’t have the effect of ordering by ID in descending order.

$args['role'] = 'subscriber';
$args['orderby'] = 'ID';
$args['order'] = 'DESC';
$args['fields'] = 'all_with_meta';      
$args['meta_query'] = $meta_query; // $meta_query is an array specified someplace above

$my_users = get_users( $args );

I’m aware that by default, WordPress is sorting by ‘login’ and in ASC order.

Any help here? Thanks in advance!

2 Answers
2

Try putting the args into an array.

$args = array(
    'role'       => 'subscriber',
    'orderby'    => 'ID',
    'order'      => 'DESC',
    'fields'     => 'all_with_meta',
    'meta_query' => $meta_query
);

$my_users = get_users( $args );

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *