First setup new schedules if you want custom time interval.
add_filter( 'cron_schedules', 'example_add_cron_interval' );
function example_add_cron_interval( $schedules ) {
$schedules['five_seconds'] = array(
'interval' => 5,
'display' => esc_html__( 'Every Five Seconds' ), );
return $schedules;
}
Setup Cron Job to sent email hourly.
add_action('init', function() {
add_action( 'csp_svd_cron', 'csp_svd_run_cron' );
if (! wp_next_scheduled ( 'csp_svd_cron' )) {
wp_schedule_event( time(), 'hourly', 'csp_svd_cron' );
}
});
function csp_svd_run_cron() {
$to = 'chandra10207@gmail.com';
$subject = 'Test Cron Email from Get Easy';
$body = 'Test email content';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
}
Leave a Reply