please how do I activate a plugin after a set period of time automatically. For example, let's say I want to activate Jetpack automatically after 3 weeks. Thanks
1 Answer
Add this to the functions.php
file of your active (child) theme-
add_action( 'init', 'wpse_393267_activate_plugin' );
function wpse_393267_activate_plugin() {
if( !function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugin_to_activate = 'jetpack/jetpack.php'; // plugin-dir/plugin-file.php
$date_to_activate = '2021-08-13'; // YYYY-MM-DD
if( is_plugin_active( $plugin_to_activate ) ) return;
if( time() >= strtotime( $date_to_activate ) ) {
activate_plugin( $plugin_to_activate );
}
}
Change the $plugin_to_activate
and $date_to_activate
as you want.
functions.php
file of your active (child) theme. Would that work for you?