2

On a multisite network, I have some plugins that are network activated so they run on every site in the network. However, I want to disable all of the network active plugins on some of the sites.

How can I do this?

1 Answer 1

3

Multisite-wide active plugins are stored in the active_sitewide_plugins site option. We can hook into this option and return an empty array (no plugins are active).

This snippet should be installed as a Must-Use Plugin.

<?php
 
/**
 * Plugin Name: Disable Sitewide Plugins
 * Plugin URI: https://wordpress.stackexchange.com/q/107732/19726
 * Author: Shea Bunge
 * Author URI: https://wordpress.stackexchange.com/users/19726/shea
 * Version: 0.1
 */

global $blog_id;
 
if ( in_array( $blog_id, array( 6, 9, 42 ) ) {
    add_filter( 'pre_site_option_active_sitewide_plugins', '__return_empty_array' );
}

Remember to replace array( 6, 9, 42 ) with an array of the blog IDs you want to disable network-wide plugins on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.