Site icon Experience Wordpress Developer Online – Design Develop and Maintenance Support

WordPress user list in descending order by name in admin panel

In WordPress, If you wish to display user list in descending order by “name” column in admin panel than here is a solutions.

function custom_order_users_by_name( $query ) {

   //Check that we are in admin otherwise return
   if( !is_admin() ) {
      return;
   }

   // We are changing the query_vars to reorder
   $query->query_vars['orderby'] = 'NAME';
   $query->query_vars['order']   = 'DESC';

   // We need to remember to return the altered query.
   return $query;
}
// Lets apply our function to hook.
add_action( 'pre_get_users', 'custom_order_users_by_name' );
Exit mobile version