Using get_user in wordpress with sorting

I have wp_users table which has a column ordering. I came to know that get_users() returns all the users.
I am using it like get_users('orderby=ordering')
I got help form this link

But unfortunately it is not sorting on ordering column.
Any help?

Related posts

Leave a Reply

1 comment

  1. You should first take a look at the users table from the database.
    The command you try is good, but the argument you use for ordering might be wrong. You should order by a column from the users table, for example user name, or user id’s..

    On the link you mentioned I’ve found these:

    orderby – Sort by ‘ID’, ‘login’, ‘nicename’, ’email’, ‘url’, ‘registered’, ‘display_name’, or ‘post_count’.

    order – ASC (ascending) or DESC (descending).

    Some working examples:

    Get users by nicename:

    $users = get_users('orderby=nicename');
    

    Other examples:

    Display users sorted by Post Count, Descending order

    $user_query = new WP_User_Query( array ( 'orderby' => 'post_count', 'order' => 'DESC' ) );
    

    Display users sorted by registered, Ascending order

    $user_query = new WP_User_Query( array ( 'orderby' => 'registered', 'order' => 'ASC' ) );