WordPress Wp-Admin Menu Hack – Hide Menus From Specific User

Hi there,

If you want to hide menus from a specific user on wp-admin, you can use this hack.

I’ve used the example bellow combined with Role Manager Plugin to hide all the wp-admin menus, displaying just “Comments” for the user.

$user_id = get_current_user_id();
//echo "user:".$user_id;
if ($user_id == 2) {
	function remove_menus () {
	global $menu;
			$restricted = array(__('Dashboard'), __('Agenda'), __('Downloads'), __('Galerias'), __('Depoimentos'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'),  __('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)]);}
	add_action('admin_menu', 'remove_menus');

Just put this code on functions.php.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: