Sometimes we need to hide some WordPress admin menu items from some users or some user roles.
We can easily do so with some coding skills but most site administrators need a way to hide those WordPress admin menu items without writing any PHP code.
In this article, we will use the Business rules WordPress plugin to hide WordPress admin menu items from specific users/roles without any coding skills, just mouse clicks.
Hide admin menu item from a specific user
- Create a new Business rule, from admin dashboard.
2. Choose a title for this business rule (workflow)
3. Choose Admin Initialize trigger
4. At the conditions area, you need to click on Add New Condition
5. Select Current logged-in user condition
6. Choose the user you need to hide the menu item from.
7. At the actions area, click on Add New Action
8. Choose Remove menu page from the actions list
9. Fill the field of the page as follows:
Menu page to remove: the part of the admin page URL after the main admin URL
For example, for the media page, the full URL is: http://localhost/wp-admin/upload.php
This textbox should have the value of: upload.php
10. Publish the rule and test it by logging in with the selected user to check if you can see the media menu item.
Hide admin menu item from a specific role
- Create a new Business rule, from admin dashboard.
2. Choose a title for this business rule (workflow)
3. Choose Admin Initialize trigger
4. At the conditions area, you need to click on Add New Condition
5. Select Current logged-in user role condition
6. Choose the role you need to hide the menu item from.
7. At the actions area, click on Add New Action
8. Choose Remove menu page from the actions list
9. Fill the field of the page as follows:
Menu page to remove: the part of the admin page URL after the main admin URL
For example, for the media page, the full URL is: http://localhost/wp-admin/upload.php
This textbox should have the value of: upload.php
10. Publish the rule and test it by logging in with the selected role to check if you can see the media menu item.
Summary
In this tutorial, we learned how to show an admin notice to one user role and to a specific user using the Business rules (Workflow) WordPress plugin.