wp_reschedule_event( int $timestamp, string $recurrence, string $hook, array $args = array() )

Reschedule a recurring event.


Parameters

$timestamp

(int) (Required) Unix timestamp (UTC) for when to run the event.

$recurrence

(string) (Required) How often the event should recur.

$hook

(string) (Required) Action hook to execute when event is run.

$args

(array) (Optional) Arguments to pass to the hook's callback function.

Default value: array()


Return

(false|void) False if the event does not get rescheduled.


Source

File: wp-includes/cron.php

function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) {
	// Make sure timestamp is a positive integer
	if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
		return false;
	}

	$crons = _get_cron_array();
	$schedules = wp_get_schedules();
	$key = md5( serialize( $args ) );
	$interval = 0;

	// First we try to get it from the schedule
	if ( isset( $schedules[ $recurrence ] ) ) {
		$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;
	} else {
		$timestamp = $now + ( $interval - ( ( $now - $timestamp ) % $interval ) );
	}

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


Changelog

Changelog
Version Description
WP-2.1.0 Introduced.