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 '';

Note: do not forget to change your URL thank you URL from code.  Above code will work in new wordpress versions.



add thank you message after wordpress comments

add thank you message after wordpress comments

Written by Purab

My name is Purab, Here is my Personal Blog: I contributor of many wordpress plugins and Drupal Modules. I am core developer of Drupal. Connect to on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to or Chat with me on Skype : purabdk

This article has 6 comments

    • Purab Kharat Reply

      We updated code for newer wordpress version. Please use code as we shown in article. That will work in latest wordpress version.

  1. erik Reply

    how to make it scroll down to the comment section and display message there?

Leave a Comment

Your email address will not be published. Required fields are marked *