WordPress at a glance

wp_unschedule_event() WP 1.0

Unschedule a previously scheduled event.

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

Is the basis for: wp_clear_scheduled_hook()

No Hooks.

Return

false/null. False if the event does not get unscheduled.

Usage

wp_unschedule_event( $timestamp, $hook, $args );
$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)
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: array()

Code of wp_unschedule_event: wp-includes/cron.php VER 4.9.8

<?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 );
}

Related Functions

From tag: cron (schedule)

No comments
    Hello, !     Log In . Register