Skip to main content
I added Step #3 because I forgot about the Admin Bar.
Source Link

OVERVIEW

While the question was about limiting editor roles to access only Widgets, the following example shows how to limit access only to Menus. However as you will see, it can easily be changed to allow only Widgets or more!

I added Step #3 because I forgot about the Admin Bar. Oops! So now whether logged into the Dashboard or logged in and on the WP website, you have full control of what is available to an editor for the 'edit_theme_capablity' sub-menus.

If you don't have a Roles & Capabilities Plugin installed, you can do this:

(If you do, skip #1 and go to #2, then #3)

:
:
on their Dashboard
<?php
  //  Using jQuery: How to allow Editors to edit only Menus (or more!)
  //  Placed in admin-footer.php as Dashboard comes from the wp-admin files

  if ( is_user_logged_in() ) { // This IF may be redundant, but safe is better than sorry...
    if ( current_user_can('edit_theme_options') && !current_user_can('manage_options') ) { // Check if non-Admin
?>
      <script>
    jQuery.noConflict();
    jQuery(document).ready(function() {
      //  Comment out the line you WANT to enable, so it displays (is NOT removed).
      //  For example, the jQuery line for MENUS is commented out below so it's not removed.

      // THEMES:  If you want to allow THEMES, also comment out APPEARANCE if you want it to display Themes when clicked. (Default behaviour)
      jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php"]').remove();
      jQuery('li#menu-appearance.wp-has-submenu a.wp-has-submenu').removeAttr("href");

      // WIDGETS:
      jQuery('li#menu-appearance.wp-has-submenu li a[href="widgets.php"]').remove();

      // MENUS:
      // jQuery('li#menu-appearance.wp-has-submenu li a[href="nav-menus.php"]').remove();

      // BACKGROUND:
      jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php?page=custom-background"]').remove();
    });
      </script>
<?php
    } // End IF current_user_can...
  } // End IF is_user_logged_in...
?>

**(3) Add this to the Theme'sfooter.php:**
What this does is to allow you to choose which option you want Editors to have on their Admin Bar.
<?php
  //  Using jQuery: How to allow Editors to edit only Menus (or more!)
  //  Placed in THEME's footer.php as the Admin Bar is added when a user is logged in

  if ( is_user_logged_in() ) { // This IF may be redundant, but safe is better than sorry...
    if ( current_user_can('edit_theme_options') && !current_user_can('manage_options') ) { // Check if non-Admin
?>
      <script>
    jQuery.noConflict();
    jQuery(document).ready(function() {
      //  Comment out the line you WANT to enable, so it displays (is NOT removed).
      //  For example, the jQuery line for MENUS is commented out below so it's not removed.

      // THEMES:
      jQuery('li#wp-admin-bar-themes').remove();

      // CUSTOMIZE:
      jQuery('li#wp-admin-bar-customize').remove();

      // WIDGETS:
      jQuery('li#wp-admin-bar-widgets').remove();

      // MENUS:
      // jQuery('li#wp-admin-bar-menus').remove();

      // BACKGROUND:
      jQuery('li#wp-admin-bar-background').remove();
    });
      </script>
<?php
    } // End IF current_user_can...
  } // End IF is_user_logged_in...
?>

If you don't have a Roles & Capabilities Plugin installed, you can do this:

(If you do, skip #1 and go to #2)

:
<?php
  //  Using jQuery: How to allow Editors to edit only Menus (or more!)

  if ( is_user_logged_in() ) { // This IF may be redundant, but safe is better than sorry...
    if ( current_user_can('edit_theme_options') && !current_user_can('manage_options') ) { // Check if non-Admin
?>
      <script>
    jQuery.noConflict();
    jQuery(document).ready(function() {
      //  Comment out the line you WANT to enable, so it displays (is NOT removed).
      //  For example, the jQuery line for MENUS is commented out below so it's not removed.

      // THEMES:  If you want to allow THEMES, also comment out APPEARANCE if you want it to display Themes when clicked. (Default behaviour)
      jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php"]').remove();
      jQuery('li#menu-appearance.wp-has-submenu a.wp-has-submenu').removeAttr("href");

      // WIDGETS:
      jQuery('li#menu-appearance.wp-has-submenu li a[href="widgets.php"]').remove();

      // MENUS:
      // jQuery('li#menu-appearance.wp-has-submenu li a[href="nav-menus.php"]').remove();

      // BACKGROUND:
      jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php?page=custom-background"]').remove();
    });
      </script>
<?php
    } // End IF current_user_can...
  } // End IF is_user_logged_in...
?>

OVERVIEW

While the question was about limiting editor roles to access only Widgets, the following example shows how to limit access only to Menus. However as you will see, it can easily be changed to allow only Widgets or more!

I added Step #3 because I forgot about the Admin Bar. Oops! So now whether logged into the Dashboard or logged in and on the WP website, you have full control of what is available to an editor for the 'edit_theme_capablity' sub-menus.

If you don't have a Roles & Capabilities Plugin installed, you can do this:

(If you do, skip #1 and go to #2, then #3)

:
on their Dashboard
<?php
  //  Using jQuery: How to allow Editors to edit only Menus (or more!)
  //  Placed in admin-footer.php as Dashboard comes from the wp-admin files

  if ( is_user_logged_in() ) { // This IF may be redundant, but safe is better than sorry...
    if ( current_user_can('edit_theme_options') && !current_user_can('manage_options') ) { // Check if non-Admin
?>
      <script>
    jQuery.noConflict();
    jQuery(document).ready(function() {
      //  Comment out the line you WANT to enable, so it displays (is NOT removed).
      //  For example, the jQuery line for MENUS is commented out below so it's not removed.

      // THEMES:  If you want to allow THEMES, also comment out APPEARANCE if you want it to display Themes when clicked. (Default behaviour)
      jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php"]').remove();
      jQuery('li#menu-appearance.wp-has-submenu a.wp-has-submenu').removeAttr("href");

      // WIDGETS:
      jQuery('li#menu-appearance.wp-has-submenu li a[href="widgets.php"]').remove();

      // MENUS:
      // jQuery('li#menu-appearance.wp-has-submenu li a[href="nav-menus.php"]').remove();

      // BACKGROUND:
      jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php?page=custom-background"]').remove();
    });
      </script>
<?php
    } // End IF current_user_can...
  } // End IF is_user_logged_in...
?>

**(3) Add this to the Theme'sfooter.php:**
What this does is to allow you to choose which option you want Editors to have on their Admin Bar.
<?php
  //  Using jQuery: How to allow Editors to edit only Menus (or more!)
  //  Placed in THEME's footer.php as the Admin Bar is added when a user is logged in

  if ( is_user_logged_in() ) { // This IF may be redundant, but safe is better than sorry...
    if ( current_user_can('edit_theme_options') && !current_user_can('manage_options') ) { // Check if non-Admin
?>
      <script>
    jQuery.noConflict();
    jQuery(document).ready(function() {
      //  Comment out the line you WANT to enable, so it displays (is NOT removed).
      //  For example, the jQuery line for MENUS is commented out below so it's not removed.

      // THEMES:
      jQuery('li#wp-admin-bar-themes').remove();

      // CUSTOMIZE:
      jQuery('li#wp-admin-bar-customize').remove();

      // WIDGETS:
      jQuery('li#wp-admin-bar-widgets').remove();

      // MENUS:
      // jQuery('li#wp-admin-bar-menus').remove();

      // BACKGROUND:
      jQuery('li#wp-admin-bar-background').remove();
    });
      </script>
<?php
    } // End IF current_user_can...
  } // End IF is_user_logged_in...
?>
Replaced the code to use jQuery to fix validation issues.
Source Link

AddIf you don't have a Roles & Capabilities Plugin installed, you can do this:

(If you do, skip #1 and go to #2)

(1) Add this to your theme's functions.php:

**Then add**(2) Add
**
**
Read [THIS][1][READ THIS][1]
, PrettySickPuppy of the jQuery snippet
<?php
  //  Using jQuery: How to allow Editors to edit only Menus (or more!)

  if ( is_user_logged_in() ) { // This IF may be redundant, but safe is better than sorry...
    if ( current_user_can('edit_theme_options') && !current_user_can('manage_options') ) { // Check if non-Admin
?>
    // NOTE: All <style> statement(s) are<script>
 "supposed" to be withinjQuery.noConflict();
 the <head> per HMTLjQuery(document).ready(function() DTD{
 for validation,
    //   else it won't validate.Comment out Ifthe thatline isn'tyou importantWANT to youenable, itso doesn'tit matterdisplays as(is allNOT browsersremoved).
      //  For supportexample, itthe anyway.jQuery line Iffor someoneMENUS wantsis tocommented "fix"out thisbelow toso beit's HTMLnot DTDremoved.

 correct, go for it!
?>

  // THEMES: <style type="text/css">
If you want to <!--allow /*THEMES, Commentalso comment out theAPPEARANCE lineif you WANTwant toit enableto (display) - As is, onlyThemes allowswhen Accessclicked. to(Default Menusbehaviour)
 */ -->
    li#menujQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php"]php"]').remove();
 { display:none; } <!  jQuery('li#menu-appearance.wp-has-submenu /*a.wp-has-submenu').removeAttr("href");

 THEMES *    // -->WIDGETS:
    li#menu  jQuery('li#menu-appearance.wp-has-submenu li a[href="widgets.php"] {php"]').remove();

 display:none; } <!-- /* WIDGETS *// -->MENUS:
    <!--  /*/ li#menujQuery('li#menu-appearance.wp-has-submenu li a[href="nav-menus.php"] {php"]').remove();

 display:none; } */ /* MENUS *// -->BACKGROUND:
    li#menu  jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php?page=custom-background"] { display:none;background"]').remove();
 } <!-- /* BACKGROUND});
 */ -->
    </style>
script>
<?php
    } // End IF current_user_can && !current_user_can...
    } // End IF is_user_logged_in...
?>

Add this to your theme's functions.php:

**Then add
**
Read [THIS][1]
, PrettySickPuppy
<?php
    if ( is_user_logged_in() ) { // This IF may be redundant, but safe is better than sorry...
    if ( current_user_can('edit_theme_options') && !current_user_can('manage_options') ) { // Check if non-Admin

    // NOTE: All <style> statement(s) are "supposed" to be within the <head> per HMTL DTD for validation,
    //   else it won't validate.  If that isn't important to you, it doesn't matter as all browsers
    //   support it anyway.  If someone wants to "fix" this to be HTML DTD correct, go for it!
?>

    <style type="text/css">
    <!-- /* Comment out the line you WANT to enable (display) - As is, only allows Access to Menus */ -->
    li#menu-appearance.wp-has-submenu li a[href="themes.php"] { display:none; } <!-- /* THEMES */ -->
    li#menu-appearance.wp-has-submenu li a[href="widgets.php"] { display:none; } <!-- /* WIDGETS */ -->
    <!-- /* li#menu-appearance.wp-has-submenu li a[href="nav-menus.php"] { display:none; } */ /* MENUS */ -->
    li#menu-appearance.wp-has-submenu li a[href="themes.php?page=custom-background"] { display:none; } <!-- /* BACKGROUND */ -->
    </style>

<?php
    } // End IF current_user_can && !current_user_can
    } // End IF is_user_logged_in
?>

If you don't have a Roles & Capabilities Plugin installed, you can do this:

(If you do, skip #1 and go to #2)

(1) Add this to your theme's functions.php:

**(2) Add
**
[READ THIS][1]
of the jQuery snippet
<?php
  //  Using jQuery: How to allow Editors to edit only Menus (or more!)

  if ( is_user_logged_in() ) { // This IF may be redundant, but safe is better than sorry...
    if ( current_user_can('edit_theme_options') && !current_user_can('manage_options') ) { // Check if non-Admin
?>
      <script>
    jQuery.noConflict();
    jQuery(document).ready(function() {
      //  Comment out the line you WANT to enable, so it displays (is NOT removed).
      //  For example, the jQuery line for MENUS is commented out below so it's not removed.

      // THEMES:  If you want to allow THEMES, also comment out APPEARANCE if you want it to display Themes when clicked. (Default behaviour)
      jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php"]').remove();
      jQuery('li#menu-appearance.wp-has-submenu a.wp-has-submenu').removeAttr("href");

      // WIDGETS:
      jQuery('li#menu-appearance.wp-has-submenu li a[href="widgets.php"]').remove();

      // MENUS:
      // jQuery('li#menu-appearance.wp-has-submenu li a[href="nav-menus.php"]').remove();

      // BACKGROUND:
      jQuery('li#menu-appearance.wp-has-submenu li a[href="themes.php?page=custom-background"]').remove();
    });
      </script>
<?php
    } // End IF current_user_can...
  } // End IF is_user_logged_in...
?>
added 215 characters in body
Source Link

Add this to your theme's functions.php:Add this to your theme's functions.php:

// Add all Editors the privilege to edit Themes, Widgets, Menus, Backgrounds

// get the the role object - editor, author, etc. (or those specially created)
$role_object = get_role( 'editor' );

// add $cap capability to this role object
// 'edit_theme_options' enables Dashboard APPEARANCE sub-menus
// for Themes, Widgets, Menus, and Backgrounds for users with that role
$role_object->add_cap( 'edit_theme_options' );

Add this to admin-footer.php (located in wp-admin directory):
What this does is to allow you to choose which option you want Editors to have.
Read THIS for more info from the author, PrettySickPuppy.


**Then add this toadmin-footer.php(located in wp-admin directory):**
What this does is to allow you to choose which option you want Editors to have.
Read [THIS][1] for more info from the author, PrettySickPuppy.

Add this to your theme's functions.php:

// Add all Editors the privilege to edit Themes, Widgets, Menus, Backgrounds

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

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

Add this to admin-footer.php (located in wp-admin directory):
What this does is to allow you to choose which option you want Editors to have.
Read THIS for more info from the author, PrettySickPuppy.

Add this to your theme's functions.php:

// Add all Editors the privilege to edit Themes, Widgets, Menus, Backgrounds

// get the the role object - editor, author, etc. (or those specially created)
$role_object = get_role( 'editor' );

// add $cap capability to this role object
// 'edit_theme_options' enables Dashboard APPEARANCE sub-menus
// for Themes, Widgets, Menus, and Backgrounds for users with that role
$role_object->add_cap( 'edit_theme_options' );

**Then add this toadmin-footer.php(located in wp-admin directory):**
What this does is to allow you to choose which option you want Editors to have.
Read [THIS][1] for more info from the author, PrettySickPuppy.
Source Link
Loading