wp_schedule_event won’t accept args

I’m trying to schedule event on hourly basis but it doesn’t work. Why, I can’t understand.

Here is a function that i use to schedule event.

add_action( 'scheduled_update_feeds', 'update_feeds', 10, 2 );

function scheduled_activation() {
    wp_schedule_event( time(), 'everyhour', 'scheduled_update_feeds', array( 0, 'everyhour' ) );
}
register_activation_hook( __FILE__, 'scheduled_activation' );

Per my understandings this should activate on plugin activation and pass schedule event based on my settings.

When I use it without array args it works, but I need to use args to pass them my scheduled function.

And this is the function

function update_feeds($ids = false, $timing = false) {
    do something
}

When i use it like this it works.

wp_schedule_event( time(), 'everyhour', 'scheduled_update_feeds' );

Even if I don’t use args in my update_feed function it doesn’t work either. The strange thing is that when I use single schedule it works.

like this

wp_schedule_single_event( time() + 10, 'scheduled_update_feeds', array($ids) );

So I don’t get it why it won’t work.

And I did defined ‘everyhour’ in my scheduled list.

add_filter( 'cron_schedules', 'my_schedule' ); 

$schedules['everyhour'] = array(
    'interval' => 60,
    'display' => __( 'Every hour', 'easy-video-grabber' )
);

I checked its existance with the Cron Schedules plugin and the schedule exists.

3 s
3

This is not a fix for your problem, but it might lead you in the right direction to solving the issue. I would suggest checking out this plugin to possibly help you find out what is going on:

WP Cron Control

It offers a quick view of cron jobs scheduled throughout your site. I recently used it to resolve a problem occurring when scheduled emails were not being sent out.

Leave a Comment