WP Cron emails not working
This should be a comment, but I don’t have comment privelages 🙁 I had this exact problem not long ago, and felt stupid when I realised it was because I had set a password on the directory…
This should be a comment, but I don’t have comment privelages 🙁 I had this exact problem not long ago, and felt stupid when I realised it was because I had set a password on the directory…
Maybe the problem happens because you don’t check if your hook is already scheduled. if ( !wp_next_scheduled( ‘first_hook’ ) ) { wp_schedule_event(time()+60, ‘daily’, ‘first_hook’); }
OK, so I’ve tested your code and I’m pretty sure it can’t run even once… And here’s why… If you’ll take a look at wp_schedule_event you’ll see this check at the top of the function: if ( !isset( $schedules[$recurrence] ) ) return false; It means that you can’t schedule event with unknown recurrence. So let’s … Read more
Unfortunately the WordPress cron jobs are only triggered when your site is visited (see Codex): The action will trigger when someone visits your WordPress site, if the scheduled time has passed. I believe this to get around the fact that many on shared hosting aren’t normally allowed to set up cron jobs (at least, not … Read more
So of course as soon as I post this I find the solution. After looking for it for a day. I had to include the file handling the request_filesystem_credentials manually in the function. For reference this was require ABSPATH . ‘wp-admin/includes/file.php’;
Ah… worked it out, though normally I rely on the traffic of the blog to hit wordpress’ fake cron I did have a daily crontab with wget to make sure site was fresh just before doing an export for an integration… but to stop it downloading the response of the request (in this case an … Read more
After some hours of investigation I deactivated W3 Total Cache plugin. Still no changes. And then I noticed WP Redis plugin.. soo I searched for Redis Object Caching on serverside and found it. When I flushed the cache, the stock showed updated stock quantity. Soo.. always double-check your caching. 😀
This might be because the plugins you were using didnt deregister the crons it setup. To remove the crons use the following code in your functions file: add_action(“init”, “clear_crons_left”); function clear_crons_left() { wp_clear_scheduled_hook(“cron_name”); } Once thats run once you can safely remove it
You can use real cron to trigger WP cron – by fetching wp-cron.php file from root (snippet from quick google search). That will take care of environment and everything.
As you’ve noted, cron jobs are only fired when someone visits your website. WordPress checks if they are any events that have been scheduled before ‘now’ that have not yet occurred – and runs them. Importantly with events that are recur according to a regularly pattern (say hourly) – their occurrence is relative not absolute. … Read more