Use a combination of switch_to_blog()
, activate_plugins()
, and deactivate_plugins()
.
You can put this in functions.php, but you’ll want to remove it once it runs:
// hook to admin init
add_action('admin_init', 'wpse_swap_plugins');
function wpse_swap_plugins() {
// set blog ID per your needs
$blog_id = 3;
// switch to the site where you want to activate/deactivate plugins
switch_to_blog($blog_id);
// activate: set your path, don't set redirect,
// don't make this network wide, don't prevent activation hooks
activate_plugins(array(
'/full/path/to/plugin/you/want/to/activate.php'
), '', false, false);
// deactivate: same arguments as activate
deactivate_plugins(array(
'/full/path/to/plugin/to/deactivate.php'
), '', false, false);
// switch context back to original site
restore_current_blog();
}
Credit to related answer: Deactivate plugin for a specific user group