wp_next_scheduled returning a past timestamp

So, here is my entire code in wp_content/plugins/my_plugin/my_plugin.php :

register_activation_hook(__FILE__, 'comunity_mails_activation');
add_action('check_mails_to_send', 'do_this_daily');
register_deactivation_hook(__FILE__, 'comunity_mails_deactivation'); 

function comunity_mails_activation() {
    wp_schedule_event(time(), 'daily', 'check_mails_to_send');
}

function comunity_mails_deactivation() {
    wp_clear_scheduled_hook('check_mails_to_send');
}

function do_this_daily() {
    wp_mail("my@email.net", "Automated Email", "Hell yeah it works!");
}

When I do echo date("d-m-Y H:i:s",wp_next_scheduled('check_mails_to_send')); in the functions.php of my theme, it prints 13-02-2013 14:22:03

Read More

So I tried to do this :

do_action('ckeck_mails_to_send');

And my mail was sent. So I wonder, do I have to unschedule the task and schedule it again for the next day and compare the two timestamps and … sounds silly…

I just don’t understand why the mail has not been sent and why it’s not scheduling it for the next day.

Thanks for reading/helping =D

Related posts

Leave a Reply

1 comment

  1. Well, as I was working on an existing site which as maaaaany plugins already installed, I figured out that there was a define(DISABLE_WP_CRON,true);

    So when you seems to have the same problem than me. Do a research of define(DISABLE_WP_CRON,true); in your files.