Support » Fixing WordPress » "Thank you"-popup after leaving a comment

  • I’m running a review site where I’ve hidden the comments (reviews) by using tabs. One tab for comments, one for specifications, etc. Because of this a lot of people don’t check the comment-tab and instead contact me to ask if their comment was received.

    Therefore I want to create a popup message thanking them for the comment and making sure that it will be displayed as soon as I approve it. The popup form is easy to create and I’m using jQuery dialog-message to style it.

    The question is how I can modify it to popup only after a comment is posted. By using ($comment->comment_approved == ‘0’) the message will popup every time the user visits the site until the comment is approved and that would be disturbing.

    Do you know how I can trigger the message only the first reload after the person leave a comment? I’m thinking about showing it the first minute after the comment is posted but it feels a bit to advanced if I have to adjust for hours, days, months, years, etc.

    Any suggestions?

Viewing 1 replies (of 1 total)
  • I guess this should be viewed as an evil workaround but it works.

    Add the following to functions.php

    add_filter('comment_post_redirect', 'redirect_after_comment');
    function redirect_after_comment($location){
    	$newurl = substr($location, 0, strpos($location, "#comment"));
    	return $newurl . '?c=y';

    Add the following where you want your message to be displayed

    if($_GET[ 'c' ] == 'y'){
          echo 'Thank you';
    } ?>

    After you leave a comment the function above will strip out #comment-id from the URL and instead replace it with ?c=y so we can check if there was a comment posted. Then we simply check if the variable ‘c’ is ‘y’. If so, we display the message, which in my case is a popup. This is the best method I could come up with.

    If you don’t like c=y you can change it to whatever you like.

Viewing 1 replies (of 1 total)
  • The topic ‘"Thank you"-popup after leaving a comment’ is closed to new replies.