4

Is there a way to remove the "Filter user list" from the top of the "All Users" screen for non-admins?

For clarification its the section which lists totals for each user role type and filters the table when clicked eg:

All (5) | Administrator (1) | Editor (3) | Subscriber (1)

1 Answer 1

5

You can use the views_users filter to alter it. Here's an example:

/**
 * Remove the users view
 */
add_filter( 'views_users', '__return_empty_array' );

if you want to remove it for every user.

Here's another example how you could remove it for non-admins (PHP 5.4+):

/**
 * Remove the users view for non-admins
 */
add_filter( 'views_users', function( $views ) 
{
    return current_user_can( 'manage_options' ) ? $views : [];
} );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.