Allow additional Editor capabilities in Wordpress admin. Allow editors to manage Widgets and Menus. Allow editors to manage Users below Editor level.
/************* EDITOR ACCESS *****************/
// Allow editors to manage Widgets and Menus
function sp_editor_capabilities() {
$editor = get_role( 'editor' );
if (!$editor->has_cap( 'edit_theme_options' ) ) {
$editor->add_cap( 'edit_theme_options' );
}
if (!$editor->has_cap( 'wpml_manage_string_translation' ) ) {
$editor->add_cap( 'wpml_manage_string_translation' );
}
if (!$editor->has_cap( 'wpml_manage_taxonomy_translation' ) ) {
$editor->add_cap( 'wpml_manage_taxonomy_translation' );
}
}
add_action('admin_head', 'sp_editor_capabilities');
// Allow editors to manage Users below Editor level
function sp_hide_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_menu_page( 'tools.php' );
remove_submenu_page( 'themes.php', 'themes.php' );
remove_submenu_page( 'themes.php', 'customize.php' );
global $submenu;
unset($submenu['themes.php'][6]);
}
}
add_action('admin_head', 'sp_hide_menu');