I have a question, I write an plugin with function that will send mail to customers after x days. I created the function.
Now, I need that the function will run only once a day.
Here is the code:
register_activation_hook(__FILE__, 'my_activation');
add_action('my_hourly_event', 'do_this_hourly');
function my_activation() {
wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'my_hourly_event');
}
function do_this_hourly() {
// do something every hour
}
From this link: http://www.paulund.co.uk/create-cron-jobs-in-wordpress
But the schedule works only when there is traffic on the site, which means that if I closed the browser, after one hour the function doesn’t run and the email doesn’t sent.
It’s possible to run cron job with WordPress?
Thanks!