pre_get_users
is the action that is fired before a user query is run. You need to check the context of the action to make sure you’re on the main users screen. You can then alter the query with any parameters accepted by WP_User_Query
.
A quick example:
function wpd_filter_users( $query ) {
$screen = get_current_screen();
if( is_admin() && 'users' == $screen->base ){
$query->set( 'role', 'Subscriber' );
}
}
add_action( 'pre_get_users', 'wpd_filter_users' );
Related Posts:
- adding existing menu page on new customer user role
- How to check if a user is in a specific role?
- How do I Enqueue styles/scripts on Certain /wp-admin Pages?
- Changing Admin Menu Labels
- Is there ANY way to remove comments function and section totally?
- How to prevent access to wp-admin for certain user roles?
- Check if user is admin by user ID
- Add “external” link to admin menu in the backend
- How to add custom submenu links in wp-admin menus?
- Edit specific nodes in WP_Admin_Bar
- How to add notification bubble for my custom admin menu page
- How to create sub menu with a URL parameter?
- Adding a menu item in the admin bar
- Only allow administrators and editors to access wp-admin
- How to remove items from +New admin menu?
- Reorder custom submenu item
- create users to site with specific language
- Prevent from deleting any user role but subscriber
- Make sub menu items a main link in the admin menu using fuctions.php
- What is the capability that permits access to WP-Admin?
- Add column to pages table
- Admin account only shows Profile and Dashboard with no activity
- How to wrap admin menus and menu headers in additional divs without modifying the WordPress core?
- How to disable admin flyout menus?
- Displaying which Role the current user is assigned to
- remove plugin admin menu in wordpress without installing plugin in v3.8.1
- How to hide a specific user role option in a user role list?
- How to prevent parent admin page from appearring as a child admin page
- Adding HTML/Text to Top of Subscriber’s Profile Backend Page
- Rename W3 Total Cache admin menu
- Custom role based users are not able to access wp-admin
- Custom roles showing HTML entities in title form field
- Users Unable to Access Dashboard/Posts/Pages
- Only allow administrators and editors to access wp-admin
- Remove query var on admin pages when ‘Save changes’ pressed
- Create a admin page in wordpress without admin menus (“wordpress sidebars”)
- Allow administrators to pick post author on custom post type edit screen
- Remove All in One Pack from the admin bar
- Cannot find an OLD Gravity Form on an OLD Word Press site [closed]
- Adding Custom Capabilites
- Restrict Author role to only 3 wp-admin pages
- wrapping ‘rest_api_init’ in ‘is_admin()’ function
- Add column to pages table
- Why is unfiltered_upload not working despite being enabled?
- Logout USER form backoffice after 30 minutes of inactivity [closed]
- Add menu option to “New Post” menu in admin bar
- Admin menu in front-end
- Remove or move admin submenus under a new menu
- Downgrade admin account by mistake
- How to set where user is redirected to after logging in at wp-login?
- How to get specific page screen ID
- Removing Dashboard Menu Items Through The Database
- WordPress Side Menu Admin Panel Default Order numbers List?
- load-{$page hook} and returned parameter
- Hide admin menu on update_option
- meta box on new admin page
- How to hide Admin Tabs? [duplicate]
- Making Comments, a sub_menu in admin menu
- Admin top level menu, pointing to an external url
- How to break line / add to ADMIN menu
- User Capabilities are not available in WP REST permission callback?
- Creating custom admin panel pages without making a plugin?
- How can I control which plugins run in the dashboard?
- how to stop wordpress admin menu from scrolling with page
- User Roles: How to hide a plugin from showing in WP-Admin?
- Is WordPress secure enough for a multi-user article directory?
- Trying to create a page as a menu item in the admin while keeping the admen panel visible
- Newly created user role not displaying on users screen
- Custom admin menu order fails if slugs are complicated
- How to check if a user is in a specific role?
- How to optimize the opening speed of admin panel?
- WordPress Admin Panel Left Sidebar No showing on Post create page
- Weird white space in admin area
- Redirect from wp-admin back to page
- How to move “Collapse Menu” to top of admin bar?
- Give wp-admin access for shop managers
- Appearance -> Menus doesn’t show
- restrict admin panel sections to users
- Remove menu item dashboard for a unique user
- How to display status messages in admin panel
- Disable flyout (popup) menus in backend
- Remove Theme menu link from Admin Panel
- Remove capability to interact with a page
- Redirection to external site on admin
- Move Custom Taxonomy Menu to Top Level Admin Menu
- Extend user search in the users.php page to allow for searching by role and excluding specified email domains from the “users search” input box
- Extend user search in the Wp backend area on the users.php page to allow for searching by email domain and role from the “users search” input box
- get_current_screen() does not return parent_file
- how to Hide all products except the General Manager role in the WordPress admin panel?
- Administrator user cannot access dashboard after localwp import
- WordPress change role from administrator to author by itself (automatically)
- How can I have an admin only non-dashboard page in my WordPress plugin
- Organizing Code in your WordPress Theme's functions.php File?
- Can I rename the wp-admin folder?
- How to remove admin menu pages inserted by plugins?
- Adding custom columns to custom post types
- Adding Fields to the Category, Tag and Custom Taxonomy Edit Screen in the WordPress Admin?
- adding custom stylesheet to wp-admin
- Can’t change language (only “English (United States)”)
- How to use “menu_order” field for posts?