Tuesday, December 16, 2014

Hide tabs in wordpress backend if user is not admin

This simple and easy script will hide the media tab in the backend of wordpress if the current user that is logged-in is not admin.
we use css to hide the tabs.
if ( !is_super_admin() ) {
 add_action('admin_head', 'hideElement');
 function hideElement() {
   echo '<style>
   #menu-media{
    display:none !important;
   }    
    </style>';
 }
}
note that this method is not the best way to hide the tabs in our wordpress backend. It is not bulletproof and secure.

No comments:

Post a Comment