wp_unschedule_event( int $timestamp, string $hook, array $args = array() )

Unschedule a previously scheduled event.


Description Description

The $timestamp and $hook parameters are required so that the event can be identified.


Parameters Parameters

$timestamp

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

$hook

(string) (Required) Action hook, the execution of which will be unscheduled.

$args

(array) (Optional) Arguments to pass to the hook's callback function. Although not passed to a callback function, these arguments are used to uniquely identify the scheduled event, so they should be the same as those used when originally scheduling the event.

Default value: array()


Top ↑

Return Return

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


Top ↑

Source Source

File: wp-includes/cron.php

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

	$crons = _get_cron_array();
	$key = md5(serialize($args));
	unset( $crons[$timestamp][$hook][$key] );
	if ( empty($crons[$timestamp][$hook]) )
		unset( $crons[$timestamp][$hook] );
	if ( empty($crons[$timestamp]) )
		unset( $crons[$timestamp] );
	_set_cron_array( $crons );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.