pre_unschedule_event
Filter HookDescription
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.Hook Information
File Location |
wp-includes/cron.php
View on GitHub
|
Hook Type | Filter |
Line Number | 493 |
Hook Parameters
Type | Name | Description |
---|---|---|
null|bool|WP_Error
|
$pre
|
Value to return instead. Default null to continue unscheduling the event. |
int
|
$timestamp
|
Unix timestamp (UTC) for when to run the event. |
string
|
$hook
|
Action hook, the execution of which will be unscheduled. |
array
|
$args
|
Arguments to pass to the hook's callback function. |
bool
|
$wp_error
|
Whether to return a WP_Error on failure. |
Usage Examples
Basic Usage
<?php
// Hook into pre_unschedule_event
add_filter('pre_unschedule_event', 'my_custom_filter', 10, 5);
function my_custom_filter($pre, $timestamp, $hook, $args, $wp_error) {
// Your custom filtering logic here
return $pre;
}
Source Code Context
wp-includes/cron.php:493
- How this hook is used in WordPress core
<?php
488 * @param int $timestamp Unix timestamp (UTC) for when to run the event.
489 * @param string $hook Action hook, the execution of which will be unscheduled.
490 * @param array $args Arguments to pass to the hook's callback function.
491 * @param bool $wp_error Whether to return a WP_Error on failure.
492 */
493 $pre = apply_filters( 'pre_unschedule_event', null, $timestamp, $hook, $args, $wp_error );
494
495 if ( null !== $pre ) {
496 if ( $wp_error && false === $pre ) {
497 return new WP_Error(
498 'pre_unschedule_event_false',
PHP Documentation
<?php
/**
* 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.
*
* @since 5.1.0
* @since 5.7.0 The `$wp_error` parameter was added, and a `WP_Error` object can now be returned.
*
* @param null|bool|WP_Error $pre Value to return instead. Default null to continue unscheduling the event.
* @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.
*/
Quick Info
- Hook Type: Filter
- Parameters: 5
- File: wp-includes/cron.php
Related Hooks
Related hooks will be displayed here in future updates.