Forums

Hide the left admin menu for a user role (3 posts)

  1. dfhectik
    Member
    Posted 10 months ago #

    Hi, I want to hide the entire left admin menu for the subscriber role without disrupting the Wp core files. Id like to get rid of everything including the divs. So all the Subscriber will see is just the remaining right "content area" of the wp Admin.

    I have manged to hide all the menu items with this great piece of code

    function remove_menu_items() {
      global $menu;
      $restricted = array(__('Links'), __('Comments'), __('Media'),
      __('Plugins'), __('Tools'), __('Users'), __('Pages'), __('Posts'), __('Dashboard'), __('Forms'), __('Appearance'), __('Settings'),__('Products'));
      end ($menu);
      while (prev($menu)){
        $value = explode(' ',$menu[key($menu)][0]);
        if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){
          unset($menu[key($menu)]);}
        }
      }
    
    add_action('admin_menu', 'remove_menu_items');
    ?>

    But I don't know how to get rid of the entire menu "Block".

  2. bmatwork
    Member
    Posted 9 months ago #

    Hi there!
    Do you know how to restrict a menu item with two words and having a blank space between?

    __('Custom Types'), ?

  3. The8thLegion
    Member
    Posted 2 months ago #

    How do you choose another role or multiple roles instead of just excluding it from subscriber?

Reply

You must log in to post.

About this Topic

Tags