0

i need to give to editor role the access on widget (or if possibile on a specific widget).

I use the code on this question and function but i have a problem. The editor can see the widget and also the "theme options" / "background" / "custom" of theme. I try to edit the code with this but nothing change:

    // Editor accesso negato file template

function custom_admin_menu() {

    $user = new WP_User(get_current_user_id());     
    if (!empty( $user->roles) && is_array($user->roles)) {
        foreach ($user->roles as $role)
            $role = $role;
    }                                                    

    if($role == "editor") { 
       remove_submenu_page( 'themes.php', 'themes.php' );
       remove_submenu_page( 'themes.php', 'nav-menus.php' ); 
       remove_submenu_page( 'themes.php', 'custom-header.php' );
       remove_submenu_page( 'themes.php', 'custom-background.php' );
       remove_submenu_page( 'themes.php', 'theme-editor.php' );

    }       
}

add_action('admin_menu', 'custom_admin_menu');
  • Thanks Mark for your reply but i dont't understand what you means... – skifast Mar 23 '15 at 15:16
0

This needs to be implemented at the widget code level for which the code in the question you start with is not a good match.

The easiest way might be to decouple the widget content editing and the widget placement. You can set up a specific page in which it is possible to manage the content of the widget, and set the access level to that page to one which editor has. This way all the admin has to do is to place the widget at the sidebar and the editor can change the content without admin's intervention.

|improve this answer|||||

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.