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
You could use WordPress’ pseudo-cron and wp_schedule_single_event. <?php // add the action. add_action(‘wpse71941_cron’, ‘wpse71941_long_running’); function wpse71941_long_running($args) { // might need to call `set_time_limit` here set_time_limit(0); // do long running stuff here // return normal time limit if($l = ini_get(‘max_execution_time’)) set_time_limit($l); } // schedule the event for right now wp_schedule_single_event( time(), ‘wpse71941_cron’, array(‘args’ => ‘for’, ‘callback’ … 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’;
wp-cron is often called a pseudo-cron, because it doesn’t run on a strict schedule. If nobody visits the site, it doesn’t run. If you schedule a wp-cron event to run, say, every 12 hours, it will run at most every 12 hours. But, if your site has very little traffic, there could be far more … Read more
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
Instead of manually removing the safety filters like this, you should simply set the correct user for these processes to be running as. When you are logged in and running a process manually, you are logged in and thus you have your credentials being used, and your permissions being used. I’m betting you’re an administrator … Read more
For those who stumble upon this later, use either option 1 or 2 found here: https://core.trac.wordpress.org/ticket/19373. “For other developers who run into this and need to work around it, either of these 2 options work: call wp_set_post_terms() to add your taxonomies after calling wp_insert_post() set up a “current user” in your script before calling wp_insert_post()”
According to the docs for this function, you can’t set up a weekly event by default. wp_schedule_event(int $timestamp, string $recurrence, string $hook, $args = array() ); The $recurrence value needs to be one of: “hourly” “twicedaily” “daily” You’ll need to test today’s date inside your callback function, my_event. Something like: function my_event() { # date(‘l’) … Read more