add_action undetected by wp_schedule_single_event
-
Hello,
I’m trying to create a simple single scheduled event and have created an action using add_action to be scheduled. However, when I schedule an event it does not have an action. I am using WP-Cron Dashboard plugin to check the status of the event and it does schedule properly and executes however there is no action in the event. The WP-Cron Dashboard indicates that the action does not exist. However, I can use the do_action() command right before I schedule the event and it works perfectly fine; executing the function in the action.
Here is a snipit of how I am trying to add_action() and then use wp_schedule_single_event().
if (isset($_POST['Submit1'])) { add_action('test_code','do_this_in_an_hour'); wp_schedule_single_event($timed3, 'test_code'); }
$timed3 is a unixtime variable that is declared outside of the if statement. Using WP-Cron Dashboard I can see that the event is scheduled at the correct time of $timed3 and disappears from the queue list at the given time. However, the action shows up as non-existent in the Dashboard. I can insert do_action(‘test_code’); in a line between add_action() and wp_schedule_single_event() and this executes perfectly fine running the desired function. Any advice on why this isn’t working would be greatly appreciated.
- The topic ‘add_action undetected by wp_schedule_single_event’ is closed to new replies.