Plugin to remove Admin menu items based on user role?

Update:

reading mike’s answer again got me thinking that you can add a new capability to a role and use that as you removal condition, so:

   // first add your role the capability like so
   // get the "author" role object
   $role = get_role( 'administrator' );

   // add "see_all_menus" to this role object
   $role->add_cap( 'see_all_menus' );

   //then remove menu items based on that
   function remove_those_menu_items( $menu_order ){
            global $menu;
            // check using the new capability with current_user_can
            if ( !current_user_can( 'see_all_menus' ) ) {
             foreach ( $menu as $mkey => $m ) {
                //custom post type name "portfolio"
                $key = array_search( 'edit.php?post_type=portfolio', $m );
                //pages menu
                $keyB = array_search( 'edit.php?post_type=page', $m );
                //posts menu
                $keyC = array_search( 'edit.php', $m );

                if ( $key || $keyB || $keyC )
                    unset( $menu[$mkey] );
             }
            }
            return $menu_order;
    }

 //Then just Hook that function to "menu_order"
        add_filter( 'menu_order', 'remove_those_menu_items' );

Old answer

I completely agree with what mike posted but if you’re not up to custom coding
Take a look at Admin Menu Editor plugin.

it lets you set access rights by level.

Leave a Comment