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?
- Setting $_SERVER[‘HTTPS’]=’on’ prevents access to wp-admin
- Any guides on creating custom admin pages?
- Remove Customize Background and Header from Appearance admin menu without CSS or JS
- wpdb::prepare was called incorrectly
- Create a global variable for use in all templates
- How to order WP_User_Query results to match the order of an array of user IDs?
- How to auto login user again after change user_login
- Handling error states with admin_post
- How to display only logged in user’s post comments in comments area
- How to track a users progress through pages by inserting data into WordPress Database?
- Admin Menus – Name Menu different from first Submenu [duplicate]
- Add a Custom Class to Admin Menus
- Creating a new page and automatically associating it with a template in WordPress
- my function doesn’t return my post from today
- Display related products with custom output
- How to override wp-admin styling
- spliting posts into two columns
- White Screen of Death – wp-admin
- Any possible way to make $wpdb->get_results() return anything else than array?
- WooCommerce – Email admin with new user details
- Echo a hierarchical list of post data from custom fields
- WP Query with custom Shortcode
- Storing Array from returned database query and using the array in a new query
- Selectbox in admin panel function linking to CSS
- What query string parameter is available for index.php, that works for both pages and blog articles?
- Sort custom meta column by other meta value
- Add New User, extra fields which are required?
- How to make my custom widget appear within WordPress widgets? Plugin development
- Modify user profile data through scripting?
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- Do not execute If User is login as Administrator or any Specific Role
- WordPress admin is incredibly slow [closed]
- Query if audio attachment AND/OR custom field
- Best practice for show data to one specific user?
- Odd / Even posts add class minus first post
- How to show a users bio on a page
- “operation successful” message
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- How to add div blocks after certain set of post
- php if username is role
- Get Page ID from Backend
- Usage of call back function of add_meta_box()
- Can I make get_users() query global?
- Show current user posts only
- PHP -> SQL Query with Summing
- How to hide posts of a specific custom category in WordPress?
- Show site content based on user role
- Removing custom sort order from admin page listing
- How to debug failed changes to posts?
- Echo array value
- How to list users like an archive page 10 users on page and have navigations
- Query pulling a single post per month
- SQL error with custom query
- Advanced Query posts
- How can I check that the acf field value is not a duplicate when adding a post?
- My Custom Post Type AJAX Query is Returning no posts – why?
- Search bar for wp menu
- Admin Panel 404 Error after login
- Call WP Rest-Api to GET /users/me returned NOTHING in console
- Class ‘WP_Privacy_Requests_Table’ not found
- If user has clicked link add class and store using PHP/WordPress
- Store data from JavaScript object to custom table in user account
- How to change the value of a variable using input field?
- spl_autoload_register is slow for WordPress sites
- Query to show average # of months all accounts with specific role have been active
- HELP! Frontend User Profile Edit Won’t Update Email
- Query doesn’t display text data with apostrophes
- How to make a parent page for author.php?
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- Editable Student file associated with basic User ID
- Adding users to another blog
- Private messaging – Getting and displaying the avatar/url of a message recipient
- Updating custom user meta
- Echo multiple tasks if a common function exists
- Shortcodes (with a space) added to php Sample
- Image not displayed
- Get author meta of all writers
- Arrange Category post manually when displayed
- Let users register weight each day and save it in DB
- You do not have permission to access this document on form submit
- How to lock users account until approvation
- Allow direct access to files/folders within WordPress to replace wp-admin
- AJAX WP_Query’s order and orderby parameters not working
- How to add custom user role into wordpress
- Custom Filtering date with newsletter