Redirect user to a custom url after submitting the comment

Not quite; the redirect occurs inline inside wp-comments-post.php

Use the filter comment_post_redirect to pass back any URL of your choice. Arguments passed are the default redirect & comment object, respectively.

Based on your comments, here’s a suggestion:

function wpse_58613_comment_redirect( $location ) {
    if ( isset( $_POST['my_redirect_to'] ) ) // Don't use "redirect_to", internal WP var
        $location = $_POST['my_redirect_to'];

    return $location;
}

add_filter( 'comment_post_redirect', 'wpse_58613_comment_redirect' );

Leave a Comment