I have user who can edit and delete posts.
I want give him access to widgets too, but not to whole Appearance, like theme change, menu,...
Is there some solution?
Thanks and sorry if my english is not good.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI have user who can edit and delete posts.
I want give him access to widgets too, but not to whole Appearance, like theme change, menu,...
Is there some solution?
Thanks and sorry if my english is not good.
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.