# Let Editors Manage Menus and Widgets

> Gives editors access to Appearance > Menus and Widgets without letting them switch themes or open the Customizer.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: users, roles, menus
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/editors-manage-menus-widgets/

## Code

```php
add_filter( 'user_has_cap', function ( $allcaps, $caps, $args, $user ) {
    if ( in_array( 'editor', (array) $user->roles, true ) ) {
        $allcaps['edit_theme_options'] = true;
    }

    return $allcaps;
}, 10, 4 );

// No Customizer for users who cannot switch themes.
add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id ) {
    if ( 'customize' === $cap && ! user_can( $user_id, 'switch_themes' ) ) {
        $caps[] = 'do_not_allow';
    }

    return $caps;
}, 10, 3 );

add_action( 'admin_menu', function () {
    global $submenu;

    if ( current_user_can( 'switch_themes' ) || empty( $submenu['themes.php'] ) ) {
        return;
    }

    foreach ( $submenu['themes.php'] as $item ) {
        if ( ! in_array( $item[2], array( 'nav-menus.php', 'widgets.php' ), true ) ) {
            remove_submenu_page( 'themes.php', $item[2] );
        }
    }
}, 999 );

add_action( 'load-themes.php', function () {
    if ( ! current_user_can( 'switch_themes' ) ) {
        wp_safe_redirect( admin_url( 'nav-menus.php' ) );
        exit;
    }
} );
```

## Notes

On block themes, menus live in the Site Editor, which editors can also open with this capability.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Let Editors Manage Menus and Widgets" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
