rveitch
8/19/2015 - 9:16 PM

Block a network-activated plugin for a single WordPress Multisite blog site.

Block a network-activated plugin for a single WordPress Multisite blog site.

<?php
//NOTE: If filters do not work due to firing too late, change the hook to on "init"

//Example: The following will disable BuddyPress on blog with id 2.
add_filter('site_option_active_sitewide_plugins', 'modify_sitewide_plugins');

function modify_sitewide_plugins($value) {
    global $current_blog;

    if( $current_blog->blog_id == 2 ) {
        unset($value['buddypress/bp-loader.php']);
    }

    return $value;
}

/*** ALTERNATIVE ***/

/**
 * Disable plugin (this will network deactivate the plugin)
 */
function deactivate_plugin_conditional() {
    if ( is_plugin_active('buddypress/bp-loader.php') ) {
        deactivate_plugins('buddypress/bp-loader.php');
    }
}
add_action( 'muplugins_loaded', 'deactivate_plugin_conditional' );

?>