Prevent Installing New Plugins and Themes
Removes the ability to install or upload new plugins and themes for every user, while still allowing updates of what is already installed.
Opens WPIDE on
Code
add_filter( 'map_meta_cap', function ( $caps, $cap ) {
if ( in_array( $cap, array( 'install_plugins', 'install_themes', 'upload_plugins', 'upload_themes' ), true ) ) {
return array( 'do_not_allow' );
}
return $caps;
}, 10, 2 );
Notes
Deactivate the snippet when you need to install something.
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.