Wordpress

How to Remove “Tools” Menu Item from WordPress Admin Menu for specific User Role

How to Remove “Tools” Menu Item from WordPress Admin Menu for specific User Role

WordPress is a powerful tool to create any type of website. It is a preferred choice of many developers and even clients who don’t have much knowledge of WordPress.

Being a developer, I am sure, you want to provide a simple admin panel to your client without any extra menu items. So, here I will show you how to remove the Tools menu item from Admin Menu for a specific User Role.

Suppose, you have created a user role “owner” and you want to hide the Tools menu item from it’s admin panel. Just copy & paste the following code in your functions.php file.Replace the ‘owner’ role with the slug of your custom role.

add_action( 'admin_init', 'ad_remove_menu_pages' );function ad_remove_menu_pages() { global $current_user; $user_roles = $current_user->roles; if ( $user_roles[0] == 'owner' ) { remove_menu_page( 'tools.php' ); }}

Please note that, this only hides the link from the menu. The page will be still accessible by direct link.

Author

About the Author

Aman Dhanda is the Founder & CTO of Webolute, with over a decade of experience and 500+ successful projects delivered worldwide. He personally oversees every project, leading an expert team of designers, developers, and digital marketers dedicated to helping businesses grow online.

WhatsApp