Hide Plugins From the Plugins Screen
Hides chosen plugins from the Plugins screen for everyone except the users you name, so clients do not deactivate them by accident.
Opens WPIDE on
Code
// Plugin files to hide (folder/main-file.php, as shown in the plugin's edit link).
$wpide_hidden_plugins = array( 'hello.php' );
// Usernames that still see every plugin.
$wpide_plugins_visible_to = array( 'admin' );
add_filter( 'all_plugins', function ( $plugins ) use ( $wpide_hidden_plugins, $wpide_plugins_visible_to ) {
$user = wp_get_current_user();
if ( in_array( $user->user_login, $wpide_plugins_visible_to, true ) ) {
return $plugins;
}
foreach ( $wpide_hidden_plugins as $file ) {
unset( $plugins[ $file ] );
}
return $plugins;
} );
Notes
Hidden plugins keep running, so pair this with blocking plugin installs on client sites.
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.