Dictionary - Projects Engine

do_action( 'before_delete_post', int $postid, WP_Post $post );

This hook is executed just before a post is deleted, at the start of wp_delete_post().

Example:

add_action( 'before_delete_post', 'before_delete_project', 99, 2 );
function before_delete_project( $postID, $post ) {

   if ( 'project' == $post->post_type ) {
      var_dump('Okay, we are good.');
      return;
   }

   // My custom stuff for deleting my custom post type here
}

To remove the callback:

remove_action( 'before_delete_post', 'action_before_delete_post', 10, 1 );

Leave a Reply

Your email address will not be published. Required fields are marked *

Close