Remote plugin activation hook

I am remote activating plugins using update_option('active_plugins,'some_plugins'); It works fine except one thing: if some plugins have to create some tables using register_activation_hook(__FILE__,'activate'); it won't create them.

When I'm activating plugins normally in wp-admin/plugins.php it works fine. Any ideas how to remote execute this activation hook or maybe there is different way to better plugin activation?

Topic remote activation plugins Wordpress

Category Web


Use activate_plugin() instead:

activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false )

You need just the first parameter, the same value as in the option.

This function will call the necessary actions:

if ( ! $silent ) {
    do_action( 'activate_plugin', $plugin, $network_wide );
    do_action( 'activate_' . $plugin, $network_wide );
}

Note: depending on where you call activate_plugin function you might need to add this:

 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.