Reputation: 1
In my wordpress website, I want to send a reminder every 30 days to the users that have not completed their profiles.
I started with making a simple example to test the cron, but it is not working. Can you please help me fix it?
The SendEmailRemiderToESN
function is not working.
// send reminder // Scheduled Action Hook function SendEmailRemiderToESN( ) { wp_mail( "[email protected]","TestCron","Hello" ); } add_action( 'SendEmailRemiderToESN', 'SendEmailRemiderToESN' ); // Custom Cron Recurrences function custom_cron_job_recurrence( $schedules ) { $schedules['every30days'] = array( 'display' => __( 'every30days', 'textdomain' ), 'interval' => 2592000, ); return $schedules; } add_filter( 'cron_schedules', 'custom_cron_job_recurrence' ); // Schedule Cron Job Event function custom_cron_job() { if ( ! wp_next_scheduled( 'SendEmailRemiderToESN' ) ) { wp_schedule_event( current_time( 'timestamp' ), 'every30days', 'SendEmailRemiderToESN' ); } } add_action( 'wp', 'custom_cron_job' );
Upvotes: 0
Views: 154
Reputation: 759
Test this ;) it's working in localhost on my mac
function custom_cron_job_recurrence_own( $schedules ) {
$schedules['every30days'] = array(
'interval' => 2592000,
'display' => __( 'every30days', 'textdomain' )
);
return $schedules;
}
add_filter( 'cron_schedules', 'custom_cron_job_recurrence_own' );
if ( ! wp_next_scheduled( 'SendEmailRemiderToESN' ) ) {
wp_schedule_event( time(), 'every30days', 'SendEmailRemiderToESN' );
}
add_action('SendEmailRemiderToESN', 'custom_cron_job_recurrence');
function custom_cron_job_recurrence() {
wp_mail(................);
};
Upvotes: 0