Remove menu items like Tools and Comments for editors and other roles, so clients only see what they use.
add_action( 'admin_menu', function (): void {
if ( current_user_can( 'manage_options' ) ) {
return;
}
remove_menu_page( 'tools.php' ); // Tools.
remove_menu_page( 'edit-comments.php' ); // Comments.
// remove_menu_page( 'edit.php' ); // Posts.
// remove_menu_page( 'upload.php' ); // Media.
}, 999 );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
Editors and shop managers see menu items they never use. A shorter menu makes wp-admin less intimidating for clients and cuts down on “what does this do?” questions.
remove_menu_page() takes the file name from the menu item’s link, such as tools.php. The callback runs late on admin_menu, after plugins have added their own items, and only for users who aren’t administrators.
Plugin menus use their page slug: for admin.php?page=wpcf7 it’s wpcf7.
Log in as an editor. Tools and Comments should be missing from the menu.