I have WP-CLI working fine using WP Multisite (or network). I can create blogs, add users, set permissions etc. But am not certain how to enable plugins for individual blogs via WP CLI.

For example, I can see for a specific blog that I have the following plugins enabled:

$ wp option get active_plugins --url=blogs.my.domain/test1
array (
  0 => 'active-directory-integration/ad-integration.php',
  1 => 'disable-comments/disable-comments.php',
  2 => 'http-authentication/http-authentication.php',
)

Which have been done by using the normal GUI and all is well.

However what I would like to do is set the options for each plugin – which I have done via WP CLI. What I am not certain how to do is manipulate the associative array via WP_CLI in order to activate the plugins for each new site, at the moment understandably the active_plugins appear as follows even though the plugin’s settings are in place:

$ wp option get active_plugins --url=blogs.my.domain/test2 array ()

So I would like to have the array set as the first example of a site where the plugins are enabled.

If someone can give me some clues as to how to manipulate and control associative arrays via WP CLI I would appreciate your help.

2 Answers
2

You could probably manipulate the option with wp option update but you shouldn’t.

It has plenty of dedicated commands for plugins, in your case it would probably be something like wp plugin activate active-directory-integration,disable-comments,http-authentication --url=blogs.my.domain/test1.

Leave a Reply

Your email address will not be published. Required fields are marked *