1

I need to show the Screen Option tab in WordPress for Admins only, and hide that tab for the rest of the users. How can I do that?

I found this: How to Hide the WordPress Screen Options Tab

function remove_screen_options_tab()
{
    return false;
}
add_filter('screen_options_show_screen', 'remove_screen_options_tab');

But it hides it for every user...

brasofilo
  • 25,496
  • 15
  • 91
  • 179
anad
  • 58
  • 7

1 Answers1

3

Look for functions.php file, inside your theme folder, and add this code:

  function remove_screen_options_tab() {
       return current_user_can( 'manage_options' );
  }
  add_filter('screen_options_show_screen', 'remove_screen_options_tab');

An admin is the only one that can 'manage_options', so that should work.

IvanRF
  • 7,115
  • 5
  • 47
  • 71
  • right solution, but not only admins have `manage_options`, thinking for custom roles. Better is, when you check the `user role` which contains `administrator` – Adrian Preuss Mar 25 '14 at 21:31
  • 1
    You're welcome! As @AdrianPreuss said, there are other options to check if the user is an Admin. [Here](http://stackoverflow.com/questions/19802492/check-if-current-user-is-administrator-in-wordpress), for instance. – IvanRF Mar 25 '14 at 21:39