function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() {}

Reschedule a recurring event.


  • int $timestamp: Timestamp for when to run the event.
  • string $recurrence: How often the event should recur.
  • string $hook: Action hook to execute when cron is run.
  • array $args: Optional. Arguments to pass to the hook’s callback function.

Return values

returns:False on failure. Null when event is rescheduled.

Source code

function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) {

	$crons = _get_cron_array();

	$schedules = wp_get_schedules();

	$key = md5(serialize($args));

	$interval = 0;

	// First we try to get it from the schedule

	if ( 0 == $interval )

		$interval = $schedules[$recurrence]['interval'];

	// Now we try to get it from the saved interval in case the schedule disappears

	if ( 0 == $interval )

		$interval = $crons[$timestamp][$hook][$key]['interval'];

	// Now we assume something is wrong and fail to schedule

	if ( 0 == $interval )

		return false;

	$now = time();

	if ( $timestamp >= $now )

		$timestamp = $now + $interval;


		$timestamp = $now + ($interval - (($now - $timestamp) % $interval));

	wp_schedule_event( $timestamp, $recurrence, $hook, $args );



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: