Title: pre_unschedule_hook
Published: February 22, 2019
Last modified: May 20, 2026

---

# apply_filters( ‘pre_unschedule_hook’, null|int|false|WP_Error $pre, string $hook, bool $wp_error )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#wp--skip-link--target)

Filter to override clearing all events attached to the hook.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#description)󠁿

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 the number of events successfully unscheduled(
zero if no events were registered with the hook). If unscheduling one or more events
fails then return either a [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
object or false depending on the value of the `$wp_error` parameter.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#parameters)󠁿

 `$pre`null|int|false|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)

Value to return instead. Default null to continue unscheduling the hook.

`$hook`string

Action hook, the execution of which will be unscheduled.

`$wp_error`bool

Whether to return a [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#source)󠁿

    ```php
    $pre = apply_filters( 'pre_unschedule_hook', null, $hook, $wp_error );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/cron.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/cron.php#L700)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/cron.php#L700-L700)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_unschedule_hook()](https://developer.wordpress.org/reference/functions/wp_unschedule_hook/)`wp-includes/cron.php` |

Unschedules all events attached to the hook.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/pre_unschedule_hook/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.7.0](https://developer.wordpress.org/reference/since/5.7.0/) | The `$wp_error` parameter was added, and a [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) object can now be returned. | 
| [5.1.0](https://developer.wordpress.org/reference/since/5.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpre_unschedule_hook%2F)
before being able to contribute a note or feedback.