I am trying to run wp_cron event that fires based on a time range. But I can set an interval that is less than a certain period of time but not in a range. The scenario is if the $wp_cron_start
is set to a time before noon, and if $wp_cron_start
is greater than the current time then it can fire that day, if these conditions are not met then set the wp_cron to run next day. The problem the first condition is not working. Say for the scenario $wp_cron_start = "08:00"
.
$wp_cron_start = "08:00";
if ($wp_cron_start < date('12:00') && $wp_cron_start > date("H:i")) {
if(!wp_next_scheduled('cron_hook')) {
wp_schedule_event(strtotime($wp_cron_start), 'daily', 'cron_hook');
}
} else {
$cron_date_start = date('D H:i:s', strtotime('+1 Weekday' . $this->options['bbna_morning_button_end_time']));
wp_schedule_event(strtotime($cron_date_start), 'daily', 'cron_hook');
}
This only sets the wp_cron for the next day. And it still does not fire.