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' );