Let an Editor edit widgets

You can use “User Role Editor” plugin and give “edit_theme_options” capability to ‘Editor’ role.

edit_theme_options capability will provide access to Widgets section to Editor role.

Alternatively if you have little bit of coding experience then you can simply add the following code to your theme’s functions.php file

function extend_editor_caps() {
    // gets the editor role
    $roleObject = get_role( 'editor' );
    
    if( !$roleObject->has_cap( 'edit_theme_options' ) ) {
        $roleObject->add_cap( 'edit_theme_options' );
    }
}
add_action( 'admin_init', 'extend_editor_caps');

Hope this helps.

Hi Samuel, your code works but it shows all Appearance options. Is there a way to only show Widgets?
Thanks, Tom

To hide any other menus you can use this plugin – https://wordpress.org/plugins/adminimize/

Once installed, navigate to Settings > Adminimize > Menu Options and then hide whichever menu you want to hide per user role.

I’ll check it out. I found another plugin which makes it easy to edit Widgets: https://wordpress.org/plugins/custom-post-widget/
Thanks, Tom

The Content Blocks allows you to display the contents of a specific custom post in a widget on in the content area using a shortcode.

I think that plugin has a different purpose and it won’t let Editors use default WordPress widgets.

But if you think it fits your requirement then no issues.

Your piece of code + Adminimize works.
It’s good to have both options. For the project I’m working on now it works with the Custom Post Widget but for other projects I’ll need your solution.
Thanks again, Tom

Thanks Tom. I also clubbed this in to an article and published on my site.



Source link