Hiding Plugins in WordPress Multisite

Home / Tutorials / Core / Hiding Plugins in WordPress Multisite

Hiding Plugins in WordPress Multisite

In this quick post, we are going to hide some plugins from blog administrators. This would be useful if you would like certain sites to have certain capabilities and restrict site owners from being able to activate new plugins. In just a few lines of code, you can hide nuisance plugins that you want to hide but not delete.

Getting Started

Add the following to functions.php in your theme folder or add it to a custom plugin

How to create a WordPress plugin from scratch

In the snippet above, we used the filter all_plugins which holds an array of all the plugins found in the plugin folder as opposed to getting the activated plugins. Within our function, we manually unset the plugin files that we do not be displayed in the list.

Next, let’s restrict certain plugins to selected blogs. Replace the previous snippet with the following

In the last snippet, we created an array of Blog IDs that we would to remove  plugins from. Then we grabbed the current Blog ID and did a conditional to check if the current blog falls within our restricted blogs.

Note

If you are not sure, what is the correct plugin key to unset, you can print the plugins for the full array

For more information about multisites and setting up multisites, here are some good sources

Create A Network

The Complete Guide To Creating A WordPress Multisite Installation

The Ultimate Guide to WordPress Multisite

Recommended Posts
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search