3

I would like to remove the filter at the top that says "Super Admin" for users that are not a "Super Admin". How do I go about doing this?

This screenshot shows what I am talking about: enter image description here

8
  • Where does this appears to you??? . . . . /wp-admin/network/users.php , /wp-admin/users.php ?
    – brasofilo
    Jul 3 '12 at 0:05
  • @brasofilo - this appears in WP-Admin > Users > All Users menu
    – Matt
    Jul 3 '12 at 1:48
  • Are you using a Custom Roles plugin?
    – brasofilo
    Jul 3 '12 at 1:54
  • 1
    @brasofilo - yes, I am using User Role Editor.
    – Matt
    Jul 3 '12 at 2:59
  • Há! Please provide as much details as you can in your Questions, otherwise it's almost a guessing game... Super Admin is a role name in WordPress Multisite, hence my first comment. . . . I see that you already have 12 questions, but still haven't earned the Analytical badge...
    – brasofilo
    Jul 3 '12 at 3:08
2

This list of filters at the top of admin screens are called Views. You can manage views using the views_{$this->screen->id} filter. Where you'd replace {$this->screen->id} with the name of the screen you'd like to manage.

In order to filter the Users screen, you can try the following:

// filter the 'users' views
add_filter( "views_users", "wse57231_filter_user_views");

function wse57231_filter_user_views($views){
  // This assumes the key for the role is 'super_admin'
  // Is the current user not a "super_admin"?

  if( !current_user_can('super_admin')){
    // Remove the super_admin view from the list of views
    unset($views['super_admin']);
  }

  return $views;
}

References: * https://developer.wordpress.org/reference/hooks/views_this-screen-id/ * http://codex.wordpress.org/Function_Reference/current_user_can

Note: Based on the comments, it sounds like Super Admin is a custom role you've created. This is partially confusing because Super Admin is also the name of a special role when using WordPress Multisite.

1

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.