K
K
kirill2709992021-08-07 18:58:54
WordPress
kirill270999, 2021-08-07 18:58:54

Sorting users alphabetically in the admin how to do it on Wordpress?

Tell me how to sort users alphabetically in the admin panel? Is this done by adding a dropdown list, or is a plugin needed rather? If a plugin, which one?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Artem Zolin, 2021-08-07
@artzolin

You can fix the parameters of the global user request on the hookpre_get_users

add_action( 'pre_get_users', 'custom_pre_get_users', 1 );
function custom_pre_get_users( $query ) {

  if ( is_admin() && $query->is_main_query() )
    $query->set( 'orderby', 'nicename' );

}

You can specify: include, nicename, email, url, registered, display_name, post_count, meta_value, meta_value_num, $meta_key

D
Dmitry Alyoshin, 2021-08-07
@ArchitectOfRuin

In alphanumeric order, users are already displayed by default in the admin panel.
If you just need to sort in every possible way by different user meta values, then the plugin https://wordpress.org/plugins/amr-users/ will do .
If you want to manually customize the output, then there is a guide with code: https://www.minddevelopmentanddesign.com/blog/how-...
However, it shows how to switch to numeric sorting instead of alphabetical. But the idea must be clear.

U
UN_Tony, 2022-02-04
@UN_Tony

and how to configure the output not alphabetically but by the date of registration? who cares about the alphabetical output for users? It's always interesting who's new registered ... and preferably without additional. plugins...

add_action( 'pre_get_users', 'custom_pre_get_users', 1 );
function custom_pre_get_users( $query ) {

  if ( is_admin() && $query->is_main_query() )
    $query->set( 'orderby', 'registered' );

}

does not work...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question