Redirect back to origin page after using get_delete_post_link()

I need to implement frontend and backend redirection after delete specific post using get_delete_post_link(). Which hook i can use? Any advice would be appreciated.

Something similar to :

?php echo wp_login_url( $redirect ); ?

I need to redirect to front-end page after post deleted, similar to wp_login_url can do.

As Barry said my code might look like below:

add_filter( 'get_delete_post_link', 'some_function', 20 );
function some_function() {
  wp_redirect( get_permalink() );
  exit;
}

Assume get_permalink will get current page where get_delete_post_link called. Any better way for this?

Topic front-end actions hooks customization Wordpress

Category Web


Theres a filter you can hook on to.

apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-{$post->post_type}_{$post->ID}" ), $post->ID, $force_delete );

Check the raw function here: http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/link-template.php#L954

Can't advise much else without seeing your code.

Edit:

its nasty buy you can do

add_filter( 'get_delete_post_link', 'some_function', 20 );
function some_function() {
  wp_redirect( home_url('/') );
  exit;
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.