0

How to let the role "editor" to control the menu the only code i found was

$role_object = get_role( 'editor' );

but i couldn't use it

1
  • 1
    "but i couldn't use it" - what do you mean? Jan 29, 2017 at 20:08

1 Answer 1

-1

Add this to your functions.php

// Allow editors to see Appearance menu
$role_object = get_role( 'editor' );
$role_object->add_cap( 'edit_theme_options' );
function hide_menu() {
 
    // Hide theme selection page
    remove_submenu_page( 'themes.php', 'themes.php' );
 
    // Hide widgets page
    remove_submenu_page( 'themes.php', 'widgets.php' );
 
    // Hide customize page
    global $submenu;
    unset($submenu['themes.php'][6]);
 
}
 
add_action('admin_head', 'hide_menu');

Source

6
  • I really searched about it and found this reply but i don't want to show all this stuff " themes , customize , widget menus " Jan 29, 2017 at 20:17
  • I need the code to let the editor control the menus only Jan 29, 2017 at 20:18
  • I changed the code, try this now Jan 29, 2017 at 20:23
  • roles are for more than menu display. enabling such a permission to someone which is not an admin, should not be done just to be able to have some more stuff in the menu. For example removing the widgets from the menu will not prevent the user from modifying them via the customizer. Jan 29, 2017 at 20:56
  • @mark i will test and add an update, but do you have any alternate solution so i can add it too? Jan 29, 2017 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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