WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a plugin that is an installer for my theme and several plugins that work with it. For the sake of discussion, let's call the additional plugins, the "payload".

The only thing I'm missing is how to activate the payload plugins via script (rather than requiring the site owner to manually click "Activate".

I'd also like to deactivate (and delete) the installer plugin once its completed its activation routines (but that's a secondary concern).

Thanks in advance for your help!

Here's what I have so far but its not activating any of the payload plugins:

function payload_activate(){

register_activation_hook(__FILE__, 'payload_activate');
share|improve this question
Do you want to activate 'Payload' when your theme is installed? – Rutwick Gangurde Dec 7 '11 at 8:07
@Rutwick, essentially yes. This plugin, when I manually click "Activate", is designed to copy over several other plugins, as well as my theme, and activate them all. Currently, everything works perfectly, except the payload plugins or not activated. – N2Mystic Dec 7 '11 at 17:22
Okay. So your plugin will install the theme and a bunch of other plugins? (asking again because I think I misunderstood your question). If yes, then the action hook is right. There might be some issue with the plugin paths you're passing to activate_plugin. – Rutwick Gangurde Dec 7 '11 at 17:43
I've tried several path variations also using default plugins (akismet/askismet.php) for example. Nothing works. – N2Mystic Dec 7 '11 at 23:27
Check this post... might help... tutzone.net/automatically-activate-plugins-in-wordpress – Rutwick Gangurde Dec 8 '11 at 8:01

You need to reference the correct path in order for WordPress to know what to activate.

For activate_plugin, it should be activate_plugin( 'plugin-name-folder/plugin-name.php' );.

For deactivate_plugins, it should be deactivate_plugins( '/plugin-name-folder/plugin-name.php' );.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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