3

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

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

  • 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_CON,true); somewhere in the code. Sorry... ^_^' – Sladix Feb 13 '13 at 21:04
  • No need to be sorry, this was super helpful! :) – Benji XVI May 13 '16 at 11:50
4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.