0

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.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.