# 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.

- Type: PHP
- Runs: Run everywhere
- Category: [Security](https://wpide.com/library/category/security/)
- Tags: security, plugins, themes, hardening
- Author: WPIDE Team
- Installs: 6
- Updated: 2026-10-28
- Page: https://wpide.com/library/block-plugin-theme-installs/

## Code

```php
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 use it

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