Do you want to hide or remove WordPress dashboard menu items from users except for admin user without using any plugins? Then you came at the right place.
By default, WordPress gives every user certain role and upon the role, it gives the menu items and permission to add or remove some settings or posts and pages. But sometimes we don’t want to show menu items to all the users except administrator.
Read also: How to Customize “Howdy” Text In WordPress Admin Bar,
And in this guide, We are going to learn how can we easily hide/remove dashboard menu items from all users except for admin with by using few lines of code.
Let’s not waste time
WordPress Hide Dashboard Menu items from All Users Except Administrator
Below we have embedded code snippets that you need to put in your WordPress Theme. Just copy the below code and paste it into your Theme’s functions.php file.
After that, save and login to any non-admin users and see the result.
WordPress Hide Admin menu items for Certain Users
This is the simple code guide for hiding admin menu items for certain users. For certain users, we need theirs user_id to hide or remove menu items.
How to get Users ID?
- Open WordPress Dashboard.
- Click on Users > All Users
- Now chose the users which you want for hiding dashboard menu.
- Now click on that user.
- Look the URL of the page.
- Find the user_id= text in URL (The after equal to, you will get the user’s id no)
- Take that id and replace 4 (the id we have shown for example:
$user->ID=4
) from the id which you get
Code Snippets to Hide WordPress Dashboard for the Single user.
Code Snippets to Hide WordPress Dashboard for the Certain users.
That’s it.
If you guys have any questions or opinion about this post, please let us know in comment section. And also, do share this guide if it was helpful for you.