Line 5 and Line 8 should be edited to meet your needs. Line 5, $restrict, lists Links and Comments as the two menus to hide, add more or replace with the WP admin menu items you woud like to remain hidden. $restrict_user contains a commas seperated list of WP menu items that will only be displayed to Administrators, and hidden to other WP user types.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
// remove unnecessary menus function remove_admin_menus () { global $menu; // all users $restrict = explode(',', 'Links,Comments'); // non-administrator users $restrict_user = explode(',', 'Media,Profile,Appearance,Plugins,Users,Tools,Settings'); // WP localization $f = create_function('$v,$i', 'return __($v);'); array_walk($restrict, $f); if (!current_user_can('activate_plugins')) { array_walk($restrict_user, $f); $restrict = array_merge($restrict, $restrict_user); } // remove menus end($menu); while (prev($menu)) { $k = key($menu); $v = explode(' ', $menu[$k][0]); if(in_array(is_null($v[0]) ? '' : $v[0] , $restrict)) unset($menu[$k]); } } add_action('admin_menu', 'remove_admin_menus'); |