Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to give the Editor Role access to editing the sidebar and it's contents. I have a text widget in there and in order to edit this text widget the user needs to be an admin - this sucks. How do I grant permission to the Editor Role that will give him access to edit the sidebar?

share|improve this question
    
This may be related: wordpress.stackexchange.com/questions/13413/… –  Elliott Sep 13 '11 at 18:33
    
It seems to be kind of what I'm looking for but I don't understand the code. It looks like hes creating a new user and assigning roles instead of editing a existing user –  Howdy_McGee Sep 13 '11 at 18:40

2 Answers 2

up vote 7 down vote accepted

The edit_theme_options capability should allow the user to edit the sidebar as described on this page : http://codex.wordpress.org/Appearance_Widgets_SubPanel

Code to add to functions.php

   $role = get_role('editor'); 
   $role->add_cap('edit_theme_options');

Edit:

This should work to prevent editor accessing themes or menus

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' ); 
    }       
}

add_action('admin_menu', 'custom_admin_menu');

I haven't had chance to test this, but it only removes them from the menu they may still be able to access them by typing in the URL directly.

share|improve this answer
    
That works like a charm but then how do I keep them from accessing menu or themes? –  Howdy_McGee Sep 13 '11 at 19:06
    
See my edited answer. –  Elliott Sep 13 '11 at 19:23
    
Fatal Error: Call to undefined function remove_menu_page() - Also I'm not worried about them typing it by URL I really doubt somebody is going to be that malicious and even so it's just themes and menus. And I can't +1 your post enough! Thanks! –  Howdy_McGee Sep 13 '11 at 19:36
    
Sorry added wrong code it should be remove_submenu_page although you still shouldn't have got the fatal error. I have edited my answer and tested and all works fine for me? –  Elliott Sep 13 '11 at 19:48
    
Still getting a fatal error with "remove_submenu_page" - I'm adding it at the top of the Functions.php in my Themes folder is that correct? –  Howdy_McGee Sep 13 '11 at 19:53

If you just want to configure this easy as possible, use the Members plugin. The capability you'll need to add is 'edit_theme_options'. Be aware that this will grant more than just the widgets area, this also grants the editor access to the entire Appearance menu. See here

http://wordpress.org/extend/plugins/members/

If you want to do this programmatically, you'll need to use add_cap().

$editor = get_role('editore');
$editor->add_cap('edit_theme_options');

You can throw that code into its own plugin, and your done.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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