Can you register two cron events in a single function?

It looks like Howdy_McGee pinpointed the issue in a comment on the original question: Make the new_interval() a method of your class and call the filter inside your activation hook (above the cron registrations): add_filter(‘cron_schedules’, array( $this, ‘new_interval’ ) );

How to schedule and publish a post after it’s ready?

There might be two ways: add_action( ‘draft_post’, ‘wpse_246730_my_function’ ); function wpse_246730_my_function( $post_id, $post ) { // Do your things // Just to stay safe remove_action( ‘draft_post’, ‘wpse_246730_my_function’ ); wp_publish_post( $post_id ); add_action( ‘draft_post’, ‘wpse_246730_my_function’ ); } Or make the post future status, and set a time after 10 or 20 mins to publish. Then use … Read more

Cron schedule not updating after run

You can use wp-cli to execute schedules without the detour via http request. Add in crontab -e. */30 * * * * wp cron event run –path=/path/to/wp-docroot By this you wont run into maximum execution time problems which could be the reason why you schedule execution got stuck.

wp_schedule_event daily at specific time

The internal WordPress cron is dependent upon site visitors to fire, unlike linux or unix cron which is fired at specific times. Generally speaking, if you have regular and frequent visitors to your website WordPress cron will run your defined task. But if you don’t have that traffic WordPress doesn’t fire the events. If your … Read more

How to code schedule / cron job

Inspect your Schedules The best way to learn coding is to turn debug on and simply inspect your output. If you want to dig deeper, then you often need a custom tool that allows you to inspect the result fast and nicely, readable formatted. I wrote a plugin for some other answer, that helps you … Read more

Schedule cron don’t work

You shouldn’t call wp_clear_scheduled_hook on every page load, because then you’re always restarting your wp-cron shcedule, with your current setup. Additionally this call: wp_clear_scheduled_hook( ‘le_do_this’ ); doesn’t make any difference, since le_do_this isn’t a hook name in your setup. You could try for example this test plugin: <?php /** * Plugin Name: Daily WP-Cron * … Read more

Detect if Cron is Running

Yes, wp_doing_cron will return true if the current request is a WP Cron request, or if it’s triggered from WP CLI https://developer.wordpress.org/reference/functions/wp_doing_cron/

Trigger background job using AJAX

I don’t think you need to worry about this running flag or unscheduling. Since you are scheduling a one-time job that will run immediately there’s no reason to unschedule it. You just need to check if a job with that name is scheduled or not and if it is (even if it is running at … Read more