Allow WordPress Editors Access to Widgets & Menus

This is something that I have been pondering for a while now and that is how to allow WordPress users that are the editor role to be able to manage widgets and menus. Sometimes although you don’t want these users to have admin rights on the site they may need to edit the sites widgets and menus. Having watched Andrew Nacin’s talk on WordPress.tv titled “Current User Can Watch This Talk” he gave an excellent example of a really easy way to do this. Just pop the code below into your themes functions.php file or better still into a plugin.

https://gist.github.com/wpmark/b11ab3395dacebc9f8d7

12 responses

  1. tried this but gave them access to all the widgets and appearance controls even though I added it to only one widget.

    1. This gives them access to the Appearance > Widgets section in the WordPress dashboard. It will also give them access to any other sections that require the user to have the edit_theme_options cap.

    2. If you only want Editors to have Widget access, you can use this to remove access to the Theme and Navigation menu items;


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

      1. Thanks!
        Quick question: Where exactly does this code go? Functions.php?

        1. Place this in your themes functions.php file or in a plugin.

      2. Gustavo Portillo Avatar
        Gustavo Portillo

        Hi Samuel,
        Thanks for the snippet of code! however I can’t get this to work. These are the steps that I did:
        1. created a new user and assigned him as “Editor”
        2. Applied code into my theme’s functions.php
        3. Logged in as the new “user” but I could not see the “Appearances” options

        Not sure If I missed a step, but I would appreciate if you could help me what I did wrong

      3. That really just removes it from the menu based on their role. They can still access it and cause mayhem via the URL.

  2. Thank you so much, it works!!!

  3. Can I add a role function that will allow me to show certain widgets to certain roles (or hide other based on roles)?
    example
    if($role == “humanresources”) {
    show_widget( ‘widget-17_text-31’ );
    }
    }

    1. Hi Sherry, I am not sure about that as it is not something I have done but it sounds like a good idea to be honest. Let me know if you manage it!

  4. This is something I’ve been thinking about for a while, so WordPress users who have the role of the editor can be able to manage widgets and menus. Sometimes you do not want these users to have administrative privileges on the site, but they may need to edit the widgets and menus of the sites. After watching Andrew Nacin’s talk on WordPress.tv titled “The Current User Can See This Post”, he gave a great example of a really easy way to do it. Just put the code below in the themes functions.php file or better yet plug it into a plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *