0

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(){
    activate_plugin('my-first-plugin.php');
    activate_plugin('my-second-plugin.php');
    }

register_activation_hook(__FILE__, 'payload_activate');
5
  • Do you want to activate 'Payload' when your theme is installed? Commented Dec 7, 2011 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
    Commented Dec 7, 2011 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. Commented Dec 7, 2011 at 17:43
  • I've tried several path variations also using default plugins (akismet/askismet.php) for example. Nothing works.
    – N2Mystic
    Commented Dec 7, 2011 at 23:27
  • Check this post... might help... tutzone.net/automatically-activate-plugins-in-wordpress Commented Dec 8, 2011 at 8:01

1 Answer 1

1

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' );.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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