How to do a redirect to the desired page after the user leaves a comment on a post in Wordpress?

After commenting WordPress automatically redirects to the post that was left review. How can I change this redirect to a specific page?
Found the solution:
when adding a new comment, on a separate page, you will have to flip to the page with the post. But this problem is solvable, you need to add one line before the closing tag in the template comments:
//here redirect the standard
The article was written in 2009 and the closing tag in the template of the review now is not (at least explicitly).
July 9th 19 at 11:12
1 answer
July 9th 19 at 11:14
Solution
I would like without the plugin. and, as I understand it, this only works with the first comment from the user - jaron85 commented on July 9th 19 at 11:17
https://ru.wordpress.org/plugins/wp-comment-redirect/ - dannie commented on July 9th 19 at 11:20
:
redirect_after_first_comment function($url, $comment) {
$comment_count = get_comments(
array(
'author_email' => $comment->comment_author_email,
'count' => true
)
);
if ( $comment_count == 1 ) {
wp_redirect('http://mojwp.ru/uslugi'); /* Here substitute the URL of your welcome page */
exit();
}
return $url = get_comment_link();
}
add_filter( 'comment_post_redirect', 'redirect_after_first_comment', 5, 2);
in functions.php insert - dannie commented on July 9th 19 at 11:23
thank you - jaron85 commented on July 9th 19 at 11:26

Find more questions by tags WordPress