How To: Hide an Admin Menu in WordPress

Have you ever needed to hide a specific admin menu from other users in WordPress? Maybe you want to hide the Plugins and Appearance menus to keep your users out of trouble. Just place the below code in your themes functions.php file to hide the Plugins menu from all users except for admin:

<?php
add_action('admin_head', 'hide_menus');

function hide_menus() {
	global $current_user;
	get_currentuserinfo();
	
	If($current_user->user_login != 'admin') {
		?>
		<style>
		   #menu-plugins{
				display:none;
			}
		</style>
		<?php
	}
}
?>

As another example lets say we want to hide the Links menu from all users that aren’t administrators in WordPress. The below code would do just that:

<?php
add_action('admin_head', 'hide_menus');

function hide_menus() {
	if ( !current_user_can('manage_options') ) {
		?>
		<style>
		   #menu-links{
				display:none;
			}
		</style>
		<?php
	}
}
?>

This is a pretty simple method of hiding menus in the WordPress admin dashboard. Enjoy!