Is there a hook that would allow me to disable and enable a specified plugin at a certain time?
For example, I would like to disable the wp contact form 7 plugin every Tuesday at 6 AM and enable it on Wednesday at 2 PM.
Is this feasible?
Thanks!
I guess I wasn't clear enough, but I only used Contact From 7 as an example. The plugin I want to disable is a random plugin, and I want to totally disable it and enable it based on a predefined time.
Is there a hook that would allow me to disable and enable a specified plugin at a certain time?
For example, I would like to disable the wp contact form 7 plugin every Tuesday at 6 AM and enable it on Wednesday at 2 PM.
Is this feasible?
Thanks!
I guess I wasn't clear enough, but I only used Contact From 7 as an example. The plugin I want to disable is a random plugin, and I want to totally disable it and enable it based on a predefined time.
You can use deactivate_plugins() function to deactivate a plugin
if ( ! wp_next_scheduled( 'deactivate_plugin_conditional_hook' ) ) {
wp_schedule_event( time(), 'twicedaily', 'deactivate_plugin_conditional_hook' );
}
add_action( 'deactivate_plugin_conditional_hook', 'deactivate_plugin_conditional_2345678999343434' );
function deactivate_plugin_conditional_2345678999343434() {
$plugin_path = 'plugin-folder/plugin-name.php';
if ( is_plugin_active($plugin_path) ) {
deactivate_plugins($plugin_path);
}
}
You can set custom event see here https://codex.wordpress.org/Function_Reference/wp_schedule_event
Note: this is not tested code