After plugin options changed hook

Use the action update_option_{$option}, where $option is the same as the second argument for register_setting(). This hook fires after the option has been updated. add_filter( ‘update_option_directory’, ‘run_after_change’, 10, 2 ); function run_after_change( $old_value, $new_value ) { // compare both values and do something } 10 is the priority, 2 the number of accepted arguments for … Read more

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’ ) );

WordPress Cron Job in Bookly Plugin [closed]

You should set up a cron job on the server to do what the plugin authors are asking you to do: execute the php command they’ve given you. Just make sure you’re not setting up WordPress’s wp_cron(), since this one is not a real cron job. From this article: When it comes to WordPress, you … Read more

Cron and WP Super Cache in Preload Mode

Will they wait until the next hit to wp-cron.php (+8 hours)? Yes. That’s why it’s important to keep this duration shorter. I usually keep it to every 5 minutes. PS: I know it’s an old question. But, wanted to answer it anyway, if someone else has the same question in the future.

Can a scheduler be set on submit of a form in wordpress?

It’s wrong to execute wp_schedule_event in plugin activation and cronjob tag. The correct tag to hook is wp. WordPress internal cron system works by “request-response” method, it checks for scheduled events immediately after any request to the whole system, after checking the scheduled events, it loads next parts of the system. So, hooking scheduling to … Read more

How to use a class within a cron job function

You’re calling a function with variables that are not defined and are required for the function to work correctly. function hourly_function() { $newClass = new newClass(); $var1 = ‘this should’; $var2 = ‘work with’; $var3 = ‘some content’; $newClass->newClass_function($var1, $var2, $var3); } You might want to move those variable to a __construct if ( ! … 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.

External cron job firing too many times

You might be calling wp-cron.php every 15 minutes, but your cron task is set to happen every 5 minutes! $schedules[“5min”] = array( ‘interval’ => 5*60, ‘display’ => __(‘Once every 5 minutes’)); … wp_schedule_event( time(), ‘5min’, ‘isa_add_every_five_minutes’ ); Change it instead to every 15 minutes