[wp-hackers] simple method to hide admin menus

Mindshare Studios info at mindsharestudios.com
Fri Sep 7 18:20:32 GMT 2007


Hey all,

Has anyone came up with a simple way to hide various admin menu items? I
know about Barun's Custom Admin Menu plugin, which is great, but I want to
add the ability to a plugin I am working on without all the extra features
for modifying the menu, etc.

I've seen code like this (from Patrick Khoo) to hide the dashboard, but I
don't really understand how one would modify it to target other menu items:

function dwpage_restrict_adminhead() {
	global $menu;

	if(current_user_can('edit_posts')){
		unset($menu[0]); // hide dashboard
	}
}

add_action('admin_head','dwpage_restrict_adminhead');


It seems like targeting menu items by their index in the menu array would
not be the best way to do this. Also how would you query the $menu array to
see what menu item mapped to what index?


Thanks,

Damian Taggart
Mindshare Studios, Inc.



More information about the wp-hackers mailing list