Hide Menu Items

If you need to hide menus from the sidebar of the administration area, you can use this. Keep in mind, this method does not block access, just hides the link.

add_action('admin_menu', 'hide_menu_links');
function hide_menu_links(){
  	global $menu,$submenu;

  	if ($submenu['plugins.php'][15][0] == 'Editor')
	unset($submenu['plugins.php'][15]);

  	if ($menu[15][0] == 'Links')
	unset($menu[15]);

}
// $menu
//     [2] => {Dashboard}
//     [4] => {separator}
//     [5] => {Posts}
//     [10] => {Media}
//     [15] => {Links}
//     [20] => {Pages}
//     [25] => {Comments}
//     [59] => {separator}
//     [60] => {Appearance
//     [65] => {Plugins}
//     [70] => {Users}
//     [75] => {Tools}
//     [80] => {Settings}
//     [99] => {separator}

// $submenu
//     [index.php] =>
//         [0] => {Dashboard}
//         [10] => {Updates}
//     
//     [edit.php] =>
//         [5] => {Posts}
//         [10] => {Add New}
//         [15] => {Categories}
//         [16] => {Post Tags}
//     
//     [upload.php] =>
//         [5] => {Library}
//         [10] => {Add New}
//     
//     [link-manager.php] =>
//         [5] => {Links}
//         [10] => {Add New}
//         [15] => {Link Categories}
//     
//     [edit.php?post_type=page] =>
//         [5] => {Pages}
//         [10] => {Add New}
//     
//     [themes.php] =>
//         [5] => {Themes}
//         [7] => {Widgets}
//         [10] => {Menus}
//     
//     [plugins.php] =>
//         [5] => {Plugins}
//         [10] => {Add New}
//         [15] => {Editor}
//     
//     [users.php] =>
//         [5] => {Users}
//         [10] => {Add New}
//         [15] => {Your Profile
//     
//     [tools.php] =>
//         [5] => {Tools}
//         [10] => {Import}
//         [15] => {Export}
//     
//     [options-general.php] =>
//         [10] => {General}
//         [15] => {Writing}
//         [20] => {Reading}
//         [25] => {Discussions}
//         [30] => {Media}
//         [35] => {Privacy}
//         [40] => {Permalinks}

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: