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)
4

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, privacy policy and cookie policy

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