I have a cron event that I am able to manually run with

wp cron event run --all

When I go to my dashboard and go to WP-Crontrol OR Advanced Cron Manager, I can see my event listed and tell it to execute. But..I can tell that it doesn't execute my script because I don't see the updates that I want to see.

How can I make sure my event is actually being scheduled?

I have the following in my theme's functions.php:

add_action('init', 'my_activation');
add_action('update_user_hours', 'do_this_hourly');

function do_this_hourly(){
    my_update_function();
    //update some stuff 
}

function my_activation() {
    if ( !wp_next_scheduled( 'update_user_hours' ) ) {
        wp_schedule_event(time(), 'hourly', 'update_user_hours');
    }
}

And I have the following in my wp-config.php:

define('ALTERNATE_WP_CRON', true);

Interestingly enough, my_update_function shows up as a cron event. I had the function name where my hook should have been previously. And now, when I try to remove the my_update_function event on Advanced Cron Manager, I get a wp-nonce error and am not allowed to remove it.

Any advice is appreciated. Thanks!

  • Is it possible it does run, but the code that runs on the event is what's broken? You should stick to WP CLI as it has the ability to list run remove etc, plugins with UIs tend to add extra complications – Tom J Nowell Nov 9 at 1:08

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.