Prevent Switching Themes
Stops anyone, administrators included, from activating a different theme, so a client cannot change the site design by accident.
Opens WPIDE on
Code
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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.