Return to Snippet

Revision: 53601
at December 2, 2011 22:18 by f6design


Updated Code
/**
 * Clean up admin menu to remove unnecessary items.
 */
function remove_admin_menus () {
	if (!current_user_can('manage_options')){ // Only proceed if user does not have admin role.
		remove_menu_page('index.php'); 				// Dashboard
		remove_menu_page('edit.php'); 				// Posts
		remove_menu_page('upload.php'); 			// Media
		remove_menu_page('link-manager.php'); 			// Links
		remove_menu_page('edit.php?post_type=page'); 		// Pages
		remove_menu_page('edit-comments.php'); 			// Comments
		remove_menu_page('themes.php'); 			// Appearance
		remove_menu_page('plugins.php'); 			// Plugins
		remove_menu_page('users.php'); 				// Users
		remove_menu_page('tools.php'); 				// Tools
		remove_menu_page('options-general.php'); 		// Settings
		
		remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=post_tag' );	// Remove posts->tags submenu
		remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=category' );	// Remove posts->categories submenu
	}
}
add_action('admin_menu', 'remove_admin_menus');

Revision: 53600
at November 29, 2011 09:09 by f6design


Initial Code
/**
 * Clean up admin menu to remove unnecessary items.
 */
 add_action('admin_menu', 'remove_admin_menus');

function remove_admin_menus () {
	global $menu;
	if (!current_user_can('manage_options')){ // Only proceed if user does not have admin role.
		$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
		end ($menu);
		while (prev($menu)){
			$value = explode(' ',$menu[key($menu)][0]);
			if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
		}
	}
}

Initial URL


Initial Description
Simplify the Wordpress admin area for clients by hiding menu items. Add this snippet to your Wordpress theme's functions.php file.

Initial Title
Remove unnecessary menu items from Wordpress admin.

Initial Tags
wordpress

Initial Language
PHP