pre_delete_post

Filters whether a post deletion should take place.

Description

apply_filters( 'pre_delete_post', (null) $null, (WP_Post) $post, (bool) $force_delete ); 

Parameters (3)

0. $null (null) => null
Whether to go forward with deletion.
1. $post (WP_Post)
Post object.
2. $force_delete (bool)
Whether to bypass the trash.

Usage

To run the hook, copy the example below.
  1. $null = apply_filters( 'pre_delete_post', $null, $post, $force_delete ); 
  2.  
  3. if ( !empty( $null ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the pre_delete_post callback 
  2. function filter_pre_delete_post( $null, $post, $force_delete ) { 
  3. // make filter magic happen here... 
  4. return $null
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'pre_delete_post', 'filter_pre_delete_post', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'pre_delete_post', 'filter_pre_delete_post', 10, 3 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/post.php  
  1. $check = apply_filters( 'pre_delete_post', null, $post, $force_delete );