How to Check if Plugin is Active in Multisite Network

When it comes to plugins installed on WordPress Multisite network, some of them can be activated either for the whole network or for a specific site of the network only.

Network activated plugin:

network activated plugins within a WordPress multisite network
When you “Network activate” a plugin, it will be automatically active for every site in your network. Yes, it sounds obvious, but just in case.

The same plugin is activated site-specific:

Site-specific plugin activation in WordPress Multisite

It shouldn’t be a problem to understand how it works, the problems could appear when we try to check whether a plugin is network or site-specifically activated in the code.

There are multiple ways to do that and each of them is quite different.

is_plugin_active_for_network()

This function returns true if a plugin is network activated. So, if we, for example, are trying to use this function on Site 1 and our plugin is activated on Site 1, but it isn’t activated networkwide, then the function will return false.

if( is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) {
	// WooCommerce is network-activated
} else {
	// WooCommerce isn't network-activated	
}

As simple as that.

is_plugin_active()

This function is quite interesting because it does two things:

  1. It checks whether a plugin is activated locally on a website you’re using it.
  2. It checks whether a plugin is network activated.

And the function returns true if at least one condition is true.

if( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
	// WooCommerce is either activated on this specific site or network-activated
}

Don’t worry, this function is safe to use outside of multisite networks as well.

Check if a Plugin is Active on a Specific Site Only

There is no such function in the WordPress core, so below is my custom code for you:

if( in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) ) {

}

You can also check a specific website of your multisite network, just don’t forget to provide $blog_id and $plugin variables.

switch_to_blog( $blog_id );

if( in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) ) {

}
	
restore_current_blog();

Check on which sites a specific plugin (in our case – WooCommerce) is active:

$sites = get_sites();
foreach( $sites as $site ) {
	switch_to_blog( $site->blog_id );
	
	if( in_array( 'woocommerce/woocommerce.php', (array) get_option( 'active_plugins', array() ) ) ) {
		echo "WooCommerce is active on {$site->blogname}";
	}
	
	restore_current_blog();
}

Conclusion

The long story short, it doesn’t matter whether you’re using is_plugin_active() or is_plugin_active_for_network() – in both cases WordPress checks the activated plugin in site options:

Function nameWhat it does exactly
is_plugin_active_for_network()get_site_option( 'active_sitewide_plugins' )
is_plugin_active()both get_option( 'active_plugins' ) and get_site_option( 'active_sitewide_plugins' )

Don’t worry about excessive database usage because these options are autoloading anyway and if you’re going to run is_plugin_active() multiple times – it is just going to check the option value from the global variables.

The database option value itself is a serialized array and looks like this:

active plugins in WordPress database
From this screenshot you can see that a couple of plugins are activated on the website – WooCommerce, Advanced Cron Manager and my Simple WP Crossposting with its add-ons.
Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X