Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to install extra plugins on certain plugin installation/activation? I tried to install them using:

$upgrader = new Plugin_Upgrader(); 
$upgrader->install(...)

But it's not working. Any suggestions? Thanks in advance!

share|improve this question
    
Yes, post more details. What is Plugin_Updater? See How to Ask. –  brasofilo Sep 24 '13 at 12:24
    
There is nothing worse than plugins relying on other plugins and/or forcing things upon the user. Why not just merge them into a single plugin? –  Waldermort Sep 24 '13 at 12:25

1 Answer 1

Yes, though its slightly complicated by this bug, which I discuss on this post (original: http://stephenharris.info/deactivate-other-plug-ins-on-deactivation/) They actually handle deactivating, rather than activating, but the principles are the same.

At time of writing that trac ticket has a patch committed for 3.7.

The following should activate 'B' when 'A' is activated:

//This all goes inside Plugin A.

//When A is activated. Activate B.
register_activation_hook(__FILE__,'my_plugin_A_activate'); 
function my_plugin_A_activate(){
    $dependent = 'B/B.php';
    if( !is_plugin_active( $dependent ) ){
         add_action('update_option_active_plugins', 'my_activate_dependent_B');
    }
}

function my_activate_dependent_B(){
    $dependent = 'B/B.php';
    activate_plugins( $dependent );
}
share|improve this answer

Your Answer

 
discard

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.