Thursday, December 15, 2022
HomeWordPress Developmentphp - understanding wp_next_scheduled - WordPress Improvement Stack Trade

php – understanding wp_next_scheduled – WordPress Improvement Stack Trade


I’ve a operate that I have been trying to get to work with wp_schedule_event. The operate sends a notification to the admin. I see the occasion get added to the wp cron occasion checklist, however it by no means runs the operate.

Operate as follows:

<?php

operate send_booking_expiration_notification(){
  // do woocomerce reserving stuff... then ship e-mail.
 wp_mail($to, $topic, $message, $headers);
}

// Schedule the send_booking_expiration_notification() operate to run every day at midnight
if ( ! wp_next_scheduled( 'send_booking_expiration_hook' ) ) {
    wp_schedule_event( strtotime( '12pm' ), 'hourly', 'send_booking_expiration_hook' );
}
add_action( 'send_booking_expiration_hook', 'send_booking_expiration_notification' );

?>

Am I misunderstanding scope or hooks. I’ve added the add_action above the operate and nonetheless no cube. I can name the operate and the have confirmed the operate works and ship e-mail, however one thing with the cron is not working.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments