Manually deactivating/activating multisite plugins

There are times that activating or deactivating plugins from the admin dashboard fails. Another option is via WP cli plugin deactivate/activate, but there are times that it will also fail specially on very large sites. The last recourse is meddling directly in the DB.

Usually, activated plugins can be found from wp_options table but for multisites, it can be found in wp_sitemeta for network activated plugins. It is in serialized

Useful commands when using the command line:

To list list the

SELECT * FROM pantheon.wp_sitemeta WHERE meta_key = 'active_sitewide_plugins';

It would return something like:

meta_id=1
site_id=1
meta_key=active_sitewide_plugins
meta_value=a:4:{s:21:"wp-redis/wp-redis.php";i:1454005607;s:44:"wp-native-php-sessions/pantheon-sessions.php";i:1454006423;s:21:"snapshot/snapshot.php";i:1454343664;s:25:"pressbooks/pressbooks.php";i:1455575944;s:11:"lti/lti.php";i:1455579470;s:35:"pressbooks-mpdf/pressbooks-mpdf.php";i:1455579470;}

The meta_value is in a PHP serialized format, so in layman terms analysis:

a:5:{ // Number of plugins network activated 
 s:21:"wp-redis/wp-redis.php";i:1454005607;
 s:44:"wp-native-php-sessions/pantheon-sessions.php";i:1454006423;
 s:21:"snapshot/snapshot.php";i:1454343664;
 s:25:"pressbooks/pressbooks.php";i:1455575944;
 s:11:"lti/lti.php";i:1455579470;
 s:35:"pressbooks-mpdf/pressbooks-mpdf.php";i:1455579470;
 // s:[string-count-of-plugin-path]:"path/of/plugin/entrypointfile.php";i:[unix-timestamp];
}

You can then add or delete network plugins based using the the UPDATE command, just make sure you take note of the meta_is as it will be unique on each site, so updating it with new values should be something like:

UPDATE pantheon.wp_sitemeta SET meta_value = 'a:2:{s:24:\"wordpress-seo/wp-seo.php\";i:1587091946;s:17:\"wp-cfm/wp-cfm.php\";i:1587091946;}' WHERE (meta_id = '22');
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.