I'm trying to do a Cron Plugin for Wordpress and I don't know why it doesn't work. I have my website in Flywheel server and I don't have access to the wp-config.php file.
My code is:
/*
Plugin Name: CronPlugin
Description:
Version: 1.0
Author: Anonymous
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
// Activación del Plugin
register_activation_hook( __FILE__, 'dcms_plugin_activation' );
function dcms_plugin_activation() {
if( ! wp_next_scheduled( 'dcms_my_cron_hook' ) ) {
wp_schedule_event( current_time( 'timestamp' ), '5seconds', 'dcms_my_cron_hook' );
}
}
// Desactivación del Plugin
register_deactivation_hook( __FILE__, 'dcms_plugin_desactivation' );
function dcms_plugin_desactivation() {
wp_clear_scheduled_hook( 'dcms_my_cron_hook' );
}
// Acción personalizada
add_action( 'dcms_my_cron_hook', 'dcms_my_process' );
function dcms_my_process() {
//error_log('Mi evento se ejecutó: '.Date("h:i:sa"));
$recepients="anonymous@anonymous.es";
$subject="Hello from your Cron Job";
$message="This is a test mail sent by WordPress automatically as per Your schedule.";
//let’s send it
wp_mail($recepients,$subject,$message);
}
add_filter( 'cron_schedules', 'dcms_my_custom_schedule');
function dcms_my_custom_schedule( $schedules ) {
$schedules['5seconds'] = array(
'interval' => 5,
'display' =>'5 segundos'
);
return $schedules;
}
I have my Plugin activated, and also the WP-CONTROL plugin which show all cron events in a tab. When I activate my Plugin the cron event is added to the list but it doesn't send me the mail.
Can anybody help me?
Thanks !
You can access your config file by connection Via FTP.
https://getflywheel.com/wordpress-support/how-do-i-access-my-site-via-sftp/