The edit_theme_options
capability controls access to the widgets page but also to the menus page.
You can then remove the menus submenu from appearance for a specific role, and if someone tries to get there by url, redirect it :
/**
* Remove the "Menus" submenu from Appearance
*/
function remove_menus()
{
if (in_array('administrator', wp_get_current_user()->roles))
{
remove_submenu_page('themes.php', 'nav-menus.php');
}
}
add_action('admin_menu', 'remove_menus');
/**
* Redirect nav-menus.php to the dashboard
*/
function redirect_menus()
{
global $pagenow;
if ($pagenow === 'nav-menus.php' && in_array('administrator', wp_get_current_user()->roles))
{
wp_redirect(admin_url());
}
}
add_action('admin_init', 'redirect_menus');
Of course, replace the administrator
role by the one you want.
Related Posts:
- How to create a clone role in wordpress
- How do I make a draft post accessible to everyone?
- Create custom user role (client) that can create another custom user role (employee) of that client
- Allow roles below admin to add subscribers only
- How to force listing contributors in authors dropdown menu
- Allow authors to edit only certain users
- How do I allow a specific Role in WordPress 3+ to only see certain plugins?
- Allow editors access to added plugins
- Temporarily disable user role login and replace with message
- Change role after the user has read all the posts in a category
- Do custom user roles have any default capabilities?
- Filter available WooCommerce payment gateways by role [closed]
- Ordering users of a specific role by last name
- How to programmatically add a user to a role?
- Can i copy administrator role to another user?
- How to change role of all users with a specific role to another role?
- How to make an author archive only for certain user role and show related CPT
- Allow users to publish child pages of the pages they have access to edit
- Is there a way to set the user Role based on email domain
- pre_get_posts Remove posts based on meta value with ‘post__not_in’
- How to prevent users with “edit_others_posts” capability from editing admin posts
- Access on specific pages in wordpress for a specific user
- How to get all users with Author role capabilities?
- Change the user role after x days
- Get (echo) all role names assigned to user
- Locking Down WordPress Application Password Permissions / Capabilities
- Making shortcode of filtered number of comments by user role
- How can I have different groups of editors only allowed to edit certain parent+subpages?
- How to let someone preview a draft?
- How can I allow user to select minimum privilege smartly
- Remove wordpress author’s capability to moderate comments on their own posts
- Are there individual memory allocations for different user roles in WordPress?
- How to redirect specific post type with user role
- Contributor disable seeing others’ posts
- Prevent Editors from Editing/Deleting Admin Accounts
- Listing child pages depending on user capability (role)
- Membership subscription, change user role when subscription runs out
- How do I display user name, role and site name using HTML tags inside a dashboard notification?
- Change user role after bulk-import
- Show metabox for a special role
- User Role Capabilities for WordPress Gutenberg Blocks
- Iframe disappears when author updates page
- How to create user specific pages (not user role!)?
- How to change a user’s role conditionally to expire after two weeks
- Custom capabilities to add, edit, remove users of a particular role only?
- Stop users of author role from editing already pending posts
- Restrict Access in Admin Panel
- Limit a user to have access to only specified pages?
- Check role of Username then echo something if administrator [closed]
- Force modified contributor role to be re-approved on edit?
- Stop contributors from editing standard posts but allow them to edit a custom post type
- How to hide a HTML element based on user role
- List users of an array of roles
- create new user role for reader
- Hide Users by user role in Worpress
- Want to know parameters that can be passed to user_can() for access control by user capabilities
- Block user roles from accessing the WordPress dashboard
- Change user role of a particular user at specific time
- Create sub-administrator role that can do everything except use or see the code editor
- Can we hook the Customizer on a post or page on the front of the site?
- display user roles in comment form
- Is it proper to build a site supporting blog visitors in WordPress?
- Removing capabilities from cloned admin role
- User role editor – Add download files capability
- Setting an expiration date for wordpress roles
- Could we know who published a post on WordPress?
- Auto Change WordPress Roles
- Error while creating a clone role in wordpress
- Custom Plugin – Blacklist/Whitelist domain email and change user role – Suggestions
- Change auth_cookie_expiration for specific roles and specific login times
- Infinite redirects at front end if logged in user is not an Admin (Toolset Access)
- Set user role, if an specific role created an user
- Block access to plugins.php for custom role
- Allow user to select role from front end edit profile form
- How to make WP page accessile only to specific user roles
- Remove add post for user role
- Restrict Author to post only to a specific category
- WordPress – Limit custom/specific user role to only have access to edit the contents of an Advanced Custom Fields Pro Options Page
- TCPDF only exports .pdf when user is administrator
- How to allow suscriber to access specific pages in dashboard?
- Enable plugins for a specific user role
- Switch role on submit button
- Custom User Role – can’t edit or publish pages?
- Dropdown of user roles that depend on variable
- Add role selector to custom registration page
- Multiple user role on registration
- Trying to get new role to have edit permissions for custom content type
- Why are all roles assigned to a user when using wp_insert_user()?
- Why does user_can return false for a capability during plugin deactivation?
- Removing Admin Bar Node Based on Role
- Create an email address that forwards to users in role
- How to update user role totals
- Custom user role doesn’t show up in admin
- Welcome email specific to user role
- update_user_meta on registration but only for default role type
- New folder and file permissions are not correct
- How to change user role setting in members plugin so that user can only edit his own post?
- Remove_role not working, gives “Call to undefined method stdClass::remove_role()”
- WordPress users roles wp-admin
- User roles empty