Using the Access plugin, I have made a custom role (Editor-Plus). This role is a clone of the Editor role, with the addition of access to the Appearance section of the admin menu as well. I am able to allow this role to access the entire Appearance section (Themes, Customize, Widgets, Menus, etc.), but I would like to be able to allow this role access to Widgets only. Is this possible?
It was discussed as an Idea for WordPress:
https://wordpress.org/ideas/topic/separate-out-the-capability-for-editing-widgets
In my opinion the implementation made is not exactly what was asked for, but I might be too strict about:
https://codex.wordpress.org/Roles_and_Capabilities#edit_theme_options
If that suits your needs, you can add or remove that capability from the User by editing it in Access > User control tab.
Please let me know if this helps.
I think I see what you're saying, but I don't see "Access > User control tab". Under Toolset, I see Access Control, but there are no user options available. I did enable "edit_theme_options" under Access Control > Custom Roles > Editor-Plus (the custom role) > General Capabilities. Is that what you're referring to?
Hi Rusty,
Beda is not available today, So, I will help you with this issue.
I see that Beda already redirected you to the open discussions in wordpress.org.
We also don't offer custom solutions to our clients but, I will do this for you to fix your issue and to be a reference to other clients as well who need the same feature.
Please try the following:
1-Go to Access > Custom Roles
2-Click Enable advanced mode button at the bottom of the table
3-Click Change permissions for the user role you need
4-Click custom roles tab
5-Click add custom role
6-Fill the role name with this value access_widgets and fill whatever you want in the role description
7-In the functions.php of your active theme, paste the following code into it
add_action('current_screen', 'prevent_widgets_access');
function prevent_widgets_access(){
$current_screen = get_current_screen();
if( !current_user_can('access_widgets')&& $current_screen ->id === "widgets" ) {
wp_redirect( home_url('/wp-admin/access-denied') );
exit;
}
}
add_action( 'admin_menu', 'adjust_the_wp_menu', 999 );
function adjust_the_wp_menu() {
$current_screen = get_current_screen();
if( !current_user_can('access_widgets')) {
$page = remove_submenu_page( 'themes.php', 'widgets.php' );
}
}
**By doing this, only the user that has the access_widgets role will be able to see the Widgets menu item and also it will be the only allowed role to access the Widgets page.
9-To apply this to all the user roles, please repeat steps 1-6 for all the other roles.
Thanks.
Thank you Mohammed, this works well! Much appreciated!