Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Hide admin menus from non-administrators

Users who aren’t administrators no longer see the Tools and Comments menus. Change the list to hide what your editors don’t need.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Category Admin area
  • Tested with WordPress 7.1
PHP
<?php

add_action(
	'admin_menu',
	static function () {
		if ( current_user_can( 'manage_options' ) ) {
			return;
		}
		foreach ( array( 'tools.php', 'edit-comments.php' ) as $page ) {
			remove_menu_page( $page );
		}
	},
	999
);

Good to know

This only hides the links: use roles and capabilities to really stop someone. Other menu files: upload.php (Media), edit.php?post_type=page (Pages), themes.php (Appearance), plugins.php, users.php, options-general.php.

In these packs

  • More admin tweaks: Useful columns, a tidier admin bar, a welcome box for clients, and fewer menus for editors.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.