WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to change the order in which users are displayed in the admin. At the moment it seems that they are order by the username.

I think I have found the right place in the wp-admin/users.php, which is around line 187:

ORDER BY user_login");

I am not 100% sure if this is right as I don't know much about the code. Could anyone confirm if I am in the right place and what I should do to change the order.

Also is it only possible that I could have an ascending or descending order for example, A,B,C,D,E or E,D,C,B,A? It would be idea if I could specify the order differently, for example, C,A,D,B,E or similar.


share|improve this question
up vote 2 down vote accepted

Nope, the line you found seems to be some basic preliminary query. Selection of users for display in table seems to be handled by WP_User_Search class. Luckily it can be hooked into easily.

Try this (changes order to descending):

add_action('pre_user_search', 'change_user_order');

function change_user_order($query) {

    $query->query_orderby = ' ORDER BY user_login DESC';

PS I am not sure if this can interfere with something else, so might require checks to only run on that specific page.

share|improve this answer
thanks, so is it right that only ascending and descending options are available for sorting or is there another method? – chentudou Dec 14 '10 at 10:41
You can change this to anything that makes sense to MySQL, this changes part of SQL request that is run to fetch users from database. – Rarst Dec 14 '10 at 11:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.