I am new to WordPress, In the WordPress admin dashboard, I have many menus, the new users that I create have all these menus but they do not need them, so I want to hide some menus based on user Role. I want only the administrator to be able to see all these menus, and the administrator to be able to hide some menus from the users based on their role.
Jese Leos
August 19, 2024
Verified user
Welcome to Wordpress! I think from your description what you're looking for isn't simply menu visibility - but adjusting capabilities. After all, you could hide a given item from the sidebar with styling, but that doesn't prevent the user from actually accessing the page it links to. There are a few ways you can do this. By default, WordPress has several user roles that can be assigned to various users. They come pre-defined with 'capabilities' that allow them to access various parts of the admin panel. For example, if users only need basic capabilities, you may want 'contributor' or similar for those users. However if the default roles aren't what you're looking for, you could certainly do this with some simple code. That would absolutely be worth trying if you have the time and are looking to learn the inner workings of how the user role system works and its relevant hooks. This article would give you a good start: https://nettsmed.no/creating-custom-user-role-in-wordpress/ But if you're looking for a quick, easy, and comprehensive solution for this, then I use the plugin below on pretty much any site that requires role/capability changes. Its very quick and easy and I've never had any issues with it, so: tl;dr https://en-ca.wordpress.org/plugins/user-role-editor/