I am attempting to create a scheduler that looks for a trigger every five minutes.
When I initialize the plugin, I get an initial response, but I’m not getting the trigger every five minutes like I’m trying to accomplish. Here’s my code:
add_filter('cron_schedules', 'add_scheduled_interval');
function add_scheduled_interval($schedules) {
$schedules['minutes_5'] = array('interval'=>300, 'display'=>'Once 5 minutes');
return $schedules;
global $schedules;
}
if (!wp_next_scheduled('sms_cron')) {
wp_schedule_event(time(), 'minutes_5', 'sms_cron');
}
add_action('sms_cron', 'send_text_alerts');
function send_text_alerts() {
//My function
}
My question is, what am I missing? Anything obvious jumping out? Thanks in advance!
you need to add the following to an action:
so something like this: