# Prevent Switching Themes

> Stops anyone, administrators included, from activating a different theme, so a client cannot change the site design by accident.

- Type: PHP
- Runs: Run everywhere
- Category: [Disable Features](https://wpide.com/library/category/disable-features/)
- Tags: disable, themes, client
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/prevent-theme-switching/

## Code

```php
add_filter( 'map_meta_cap', function ( $caps, $cap ) {
    if ( 'switch_themes' === $cap ) {
        $caps[] = 'do_not_allow';
    }

    return $caps;
}, 10, 2 );
```

## Notes

Deactivate the snippet when you do want to change themes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Prevent Switching Themes" 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/
