Saying thank you is always good manners. In article, i have code for, add thank you message after wordpress comments after adding comments added by users. I got the same request from many of clients for adding the thank you message after putting comments after by the user who comes to site.
It was good to have this functionality. User will remember your site and you should send the thank you email to user for adding the comment to your wordpress website. For professional sites, it is very great functionality.
add thank you message after wordpress comments
In this article I will show how to add custom message after getting comments from users. For this we going use the wordpress api. WordPress filters are very useful. You can find all wordpress hooks and filters in wp-includes/default-filters.php file.
- Method First
add_filter('comment_post_redirect', 'redirect_after_comment'); function redirect_after_comment($location){ $newurl = substr($location, 0, strpos($location, "#comment")); return $newurl . '?c=y'; } if($_GET[ 'c' ] == 'y'){ echo 'Thank you your comemnt'; }
Open your functions.php file from your active wordpress theme folder. copy paste the following code in that file. This is very simple trick but still it is really useful.
- Method Second
For this method you need to create the “Thank you” page in wordpress site than open functions.php file and put following code in that file.
// Redirect to thank you post after comment add_action('comment_post_redirect', 'redirect_to_thank_page'); function redirect_to_thank_page() { return 'https://purabtech.in/thank-you'; }
Note: do not forget to change your URL thank you URL from code. Above code will work in new wordpress versions.
what issue you are facing tell me.
Dude,
you need to start monitoring your comments!
Didn’t work for me as well and for the comments, it seems this site has been abandoned.
hi
i try this code but it’s not working for me.
my wordpress version is 4.0
We updated code for newer wordpress version. Please use code as we shown in article. That will work in latest wordpress version.
how to make it scroll down to the comment section and display message there?