pre_unschedule_event
Filter to override unscheduling of events.
Returning a non-null value will short-circuit the normal unscheduling process, causing the function to return the filtered value instead.
For plugins replacing wp-cron, return true if the event was successfully unscheduled, false or a WP_Error if not.
Usage
add_filter( 'pre_unschedule_event', 'wp_kama_pre_unschedule_event_filter', 10, 5 );
/**
* Function for `pre_unschedule_event` filter-hook.
*
* @param null|bool|WP_Error $pre Value to return instead.
* @param int $timestamp Unix timestamp (UTC) for when to run the event.
* @param string $hook Action hook, the execution of which will be unscheduled.
* @param array $args Arguments to pass to the hook's callback function.
* @param bool $wp_error Whether to return a WP_Error on failure.
*
* @return null|bool|WP_Error
*/
function wp_kama_pre_unschedule_event_filter( $pre, $timestamp, $hook, $args, $wp_error ){
// filter...
return $pre;
}
- $pre(null|true|false|WP_Error)
- Value to return instead.
Default: null to continue unscheduling the event - $timestamp(int)
- Unix timestamp (UTC) for when to run the event.
- $hook(string)
- Action hook, the execution of which will be unscheduled.
- $args(array)
- Arguments to pass to the hook's callback function.
- $wp_error(true|false)
- Whether to return a WP_Error on failure.
Changelog
| Since 5.1.0 | Introduced. |
| Since 5.7.0 | The $wp_error parameter was added, and a WP_Error object can now be returned. |
Where the hook is called
pre_unschedule_event
wp-includes/cron.php 520
$pre = apply_filters( 'pre_unschedule_event', null, $timestamp, $hook, $args, $wp_error );