hooks - Redirect back to origin page after using get_delete_post_link()

admin2025-01-08  5

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?

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?

Share Improve this question edited Jul 15, 2012 at 13:44 Ivan Slaughter asked Jul 14, 2012 at 12:52 Ivan SlaughterIvan Slaughter 2674 silver badges14 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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;
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736266568a1131.html

最新回复(0)