How to enable the theme editor cap for an editor role?

I am trying to add/enable the theme editor for the editor role. The editor role by default doesn’t have the option to manage theme options, so I addded this to functions.php:

// get the the role object
$role_object = get_role( 'editor' );

// add $cap capability to this role object
//$role_object->add_cap( 'edit_theme_options' );
$role_object->add_cap( 'manage_options' );

But still, I don’t see the theme editor option. In the end, I want the theme editor to be the only submenu option.

Any suggestions?

1 Answer
1

The edit_themes capability is what allows access to Appearance > Theme Editor:

function wpse243341_modify_editor_role() {
    $role = get_role( 'editor' );
    $role->add_cap( 'edit_themes' ); 
}
add_action( 'admin_init', 'wpse243341_modify_editor_role');

Leave a Comment