Delete custom post type in front end and redirect to specific page

I made it possible to delete the post from the front end with this code (https://wordpress.stackexchange.com/questions/132196/get-delete-post-link-redirect):

<a class="button-iv" onclick="return confirm('are you sure...?');" href="<?php echo get_delete_post_link( $post->ID ); ?>" title="delete doc">Delete doc</a>

In functions.php i have this code for redirect after deleting the post:

function wpse132196_redirect_after_trashing_get() {
    if ( array_key_exists( 'trashed', $_GET ) && $_GET['trashed'] == '1' ) {
    if (!is_admin()) {
       wp_redirect( home_url('/doc-area/doc') );
       exit;
    }
    }
}
add_action( 'parse_request', 'wpse132196_redirect_after_trashing_get' );

This works fine. But now I would like to create a different redirect for each custom post type. So I add this control

if ( 'extra' == get_post_type() )

And the function become:

function wpse132196_redirect_after_trashing_get() {
if ('extra' == get_post_type()) {
    if ( array_key_exists( 'trashed', $_GET ) && $_GET['trashed'] == '1' ) {
    if (!is_admin()) {
        wp_redirect( home_url('/doc-area/doc') );
        exit;
       }
      }
    }
}
add_action( 'parse_request', 'wpse132196_redirect_after_trashing_get' );

But now the redirect doesn’t work. How can I get a redirect for each specific post type?

Answer

You can use the parameter in the parse_request action hook to check what post type is. check the below code.

function wpse132196_redirect_after_trashing_get( $extra_query_vars ) {
    if ( $extra_query_vars['query_vars']['post_type'] ==  'extra' ) { // $extra_query_vars['extra_query_vars']['post_type']
        if ( array_key_exists( 'trashed', $_GET ) && $_GET['trashed'] == '1' ) {
            if (!is_admin()) {
                wp_redirect( home_url('/doc-area/doc') );
                exit;
            }
        }
    }
}
add_action( 'parse_request', 'wpse132196_redirect_after_trashing_get' );