This snippet is good enough, use it with $wpdb
. In this case I would use :
<?php
add_action( 'before_delete_post', 'my_func' );
function my_func( $postid ){
// We check if the global post type isn't ours and just return
global $post_type;
if ( $post_type != 'my_custom_post_type' ) return;
// My custom stuff for deleting my custom post type here
}
?>