3

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.

1

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.

  • OK that is helpful, however there is an issue: – Paul Osborne Nov 26 '14 at 9:19
1

Sorry need a long comment, so having to use an answer:

What you suggest works, but I have found an issue(bug?):

$ wp option get active_plugins --url=blogs.my.domain/undersea/submarinearray    (
)

Which is what I would expect, then activate the plugin:

$ wp plugin activate active-directory-integration --url=blogs.my.domain/undersea/submarine
Warning: Could not activate the 'active-directory-integration' plugin.

Which suggests that the plugin has not activated, but:

$ wp option get active_plugins --url=blogs.my.domain/undersea/submarinearray     (
  0 => 'active-directory-integration/ad-integration.php',
)

Tells me that it is active, which is not what I expected.

So deactivating the plugin:

$ wp plugin deactivate active-directory-integration --url=blogs.canterbury.ac.uk/undersea/submarine
Success: Plugin 'active-directory-integration' deactivated.

and to confirm:

$ wp option get active_plugins --url=blogs.my.domain/undersea/submarinearray (
)

Which is what I would expect.

So I get a correct message when a plugin is deactivated but not when one is, this is just a bit misleading.

I appreciate being able to do what I need to do, however the misleading message is not as helpful as I would like.

Many thanks

P.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.