I first thought that pre_user_query
would be that hook for the job. But I think using the equivalent of pre_get_posts
, which is pre_get_users
, would be suitable here.
You also said you wanted to run this in admin. So we will check that before running this.
function my_custom_order_users_by_id( $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'] = 'ID';
$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', 'my_custom_order_users_by_id' );
Related Posts:
- Jquery no more loading, load-scripts.php not found (404)
- Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress
- Get all user meta by meta key instead of ID
- How to get a list of all possible values of a specific user meta key?
- Programmatically create page when saving custom post type post
- How can I open up my administrative panel to everyone?
- retain querystring values when savincustom options in admin
- I installed WordPress locally now how do I login?
- Woocommerce display orders with products from specific categories to specific admins
- Hide Approved status for certain users in users list
- Editing the term_order field
- Access to “My Site” is missing from the admin bar
- Forbid certain users to access a specific page
- One folder to be accessible by one user
- How to create a User Role and give permission to only use Web Stories plugin?
- How can I catch WordPress custom settings page slug has already changed?
- Any possible way to make $wpdb->get_results() return anything else than array?
- Custom filter in admin edit custom post type responding with invalid post type?
- WooCommerce – Email admin with new user details
- Accessing the database from a plugin outside of action hooks
- Echo a hierarchical list of post data from custom fields
- How to create a form and display its content as table in admin panel?
- Create WP_Query to search for posts by their categories or their parent/child categories
- WP Query with custom Shortcode
- Storing Array from returned database query and using the array in a new query
- Correct folder permissions?
- User’s total comment count excluding comments on their own posts
- Namespace spl_autoload problem in WordPress admin
- mysql query from wordpress page using custom table
- Selectbox in admin panel function linking to CSS
- WordPress 3.2 query_posts and pagination, permalinks issue
- User management system similar to wordpress one?
- only show container with next/prev links if they exist?
- mysql query two database tables, users and usermeta and sort by custom meta int value
- Show all posts by author
- Unreadable pagination
- remove wp floating submenu in wp dashboard
- What query string parameter is available for index.php, that works for both pages and blog articles?
- ACF: how do I get the fields and its values of a specific group?
- My custom wp-admin php files stopped working
- Custom user login page by creating a plugin
- Sort custom meta column by other meta value
- Call to undefined function wp() in wp-blog-header.php
- Programmatic Login from 3rd Party site
- Set WP_query ‘order’ option by another tables value
- Cannot access wp-admin (wordpress dashboard)
- Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
- Remove metabox from WordPress menu editor page?
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Add New User, extra fields which are required?
- user_profile_update_errors hook not executing
- How to make my custom widget appear within WordPress widgets? Plugin development
- Modify user profile data through scripting?
- Increase offset while looping
- Get users that likes the post
- Long running queries
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- running wp-cron.php using php not wget
- add_cap not working
- How to pre populate a form field with a link of a current user’s author profile?
- PHP version problem?
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Do not execute If User is login as Administrator or any Specific Role
- WordPress admin is incredibly slow [closed]
- inserting a post from an extern php file but post content doesn’t show on wp site
- Query if audio attachment AND/OR custom field
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- wordpress archive a user
- Best practice for show data to one specific user?
- register_taxonomy() take much queries
- Call to undefined function get_userdata() in plugin
- WordPress SQL injection
- How to change menu labels
- Building a WordPress App
- Which is the correct way to conditionally enqueue a CSS file?
- Odd / Even posts add class minus first post
- WordPress admin-ajax.php
- get_users meta_query: REGEXP not working for matching new lines
- Change CSS based on is_user_logged_in
- How to show a users bio on a page
- “operation successful” message
- How do I modify the custom footer text and get theme version number to show in wordpress admin?
- unable to use ‘new WP_Query’ in AJAX call
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- WordPress ajax-action failing because of newline in response
- get_total () returns 0 – woocommerce [closed]
- How to list commenters and days since last commented
- How to add div blocks after certain set of post
- php if username is role
- How to overwrite orderby with add_query_var
- Can’t update multiple rows with $wpdb query
- Customizing Users in Admin Area
- Link blogname and blogdescription to the Options Framework
- Get categories names as an array to use it in theme settings
- working with term_relationships table
- Get Page ID from Backend
- How do you create two separate Register pages?
- Usage of call back function of add_meta_box()