geeky · wp hacks

the ultimate comment idea

i really like skippy’s self comment moderation plugin.

The basic idea is that if the user supplies a valid email address, and they check that email account, then the commenter is most likely not a spammer.

altho not foolproof, i like it better than asking people entering a certain code. plus this way it does not only fight spam, it also fights flamers. because from my personal experience, most flamers are too chicken **** to leave their real email addresses. this way i don’t need to waste my time to read their worthless comments.

i think it’s kinda annoying to ask your regular commenters repeatedly moderate their own comments. so i added a little modification where your script tests if the commenter’s email already exists in the database or not. if it does, it will be automatically approved, otherwise an email with an approval link is sent to the user.

i also thought of the idea to apply skippy’s filter only after a post is certain days old.

you are welcome to use either or both.

How to use my trick:

1. install skippy’s plugin. modify your $seed variable. activate it. upload moderation.php to your wp root directory.
2. make sure in your wp control panel, under options -> discussion “An administrator must approve the comment (regardless of any matches below)” is UNCHECKED.
3. open wp-comments-post.php and find the line:

$wpdb->query("INSERT INTO $tablecomments

if you wish to use auto unapprove comments after the post is __ many days old. add above

//// Auto unapprove comments if a post is ___ days old $how_old = 7; 
// 7 days $current_time = time(); 
$post_date = $wpdb->get_var("SELECT post_date FROM $tableposts WHERE ID='$comment_post_ID'"); 
$post_time = mysql2date('U', $post_date) + $how_old * 24 * 3600; 
if($post_time < $current_time && $approved == 1) { 
	$approved = 0; 
}
//// End unapprove comments if a post is ___ days old

if you wish to use auto unapprove comments if the commenter’s email addy is new. add above

//// Auto unapprove comments if the commenter's email is not recognized from the database 
$comment_author_email_exist = $wpdb->get_var("SELECT comment_author_email FROM $tablecomments WHERE comment_author_email='$email' AND comment_approved='1' LIMIT 1"); 
if(empty($comment_author_email_exist) && $approved == 1) { 
	$approved = 0; 
} 
//// End unapprove comments if the commenter's email is not recognized from the database

29 thoughts on “the ultimate comment idea

        1. you are supposed to…. any replies to your commenter will be emailed to you. altho i could have write a check to make sure you don’t get your own comments notification.. but i haven’t done that. it has nothing to do with the plugin tho.

  1. I have a question for ya… how do you test to see if the gravatar exists or not? I would like to add a 2px white padding plus a grey border, but I don’t want that to show up on comments that don’t have gravatars, does that make any sense?

    1. Great way to go dodo! Skippy’s idea was cool, and I like the modification so that you odn’t have to repeatedly check everytime you comment. Although it’s not fool proof as you said, best said by ecila:

      What if like someone is a fequent commenter, and their email is in the db, and their comments are automatically approved, but a flammer just copy and paste the other person’s email address into their comment, so their comments will be approved as well.

      Mmm. It’s still a good idea.

    2. when the commenter’s avatar does not exist, it returns a 1×1 pixel gif so just use getimagesize on the gravatar and if the width is not 1, do this.. else do nothing.

      1. My php skills are a bit rusty. Here’s the code I’ve placed inside my wp-comments:

        <?php
        $size = getimagesize(gravatar());
        if ($size[0] != 1 && $size[1] != 1) { ?>
        <a href="http://gravatar.com/" target="_blank"><img src="<?php gravatar("", 40); ?>" alt="<?php comment_author() ?>'s Gravatar. Upload your Gravatar for free
        at Gravatar.com!" border="0" class="grav" /></a>
        <?php } ?>

        What parameters do i need for the getimagesize function?

        1. bubs, this is what i did. in your gravatar.php plugin file. add these code before the } of the function
          $imagesize = getimagesize($out);
          if($imagesize[0] != 1) {
          $out = "<a href=\"http://gravatar.com/\" rel=\"external\" title=\"".$author."'s gravatar. Upload your own gravatar at gravatar.com\"><img src=\"".$out."\" class=\"gravatar\" alt=\"".$author."'s gravatar. Upload your own gravatar at gravatar.com\" /></a>\n";
          echo $out;
          }

          btw, somehow it doesn’t work with rating. so i just commented out this line
          $out .= "&rating=".$rating;

        2. btw, i’m removing my implementation, it slows my comments form loading too much 😦

          i found yesterday that there’s an alternative called favatars but i think i’m just gonna not do either.

          1. It is a bit laggy, but I don’t know if it’s the gravatars themselves. My comments became slow when I added the getimagesize to the grav function. Of course, I could be wrong 😉

              1. Before I decided to add the border and padding, the 1×1 pixel image didn’t make a difference in my comments. There wasn’t any space or anything. When I was using the b2 plugin, however, there was a small space. Maybe the WP plugin takes that into consideration somehow? I dunno.

                1. as far as i know.. it does not. yes if you do not put border and stuff, it should not affect your layout. however it looks bad without border IMO.

  2. cool idea dodo! 🙂 but about the comments being automatically approved. What if like someone is a fequent commenter, and their email is in the db, and their comments are automatically approved, but a flammer just copy and paste the other person’s email address into their comment, so their comments will be approved as well.

    That wouldn’t be too good now 😦

    1. well first the flamer has to know which email the frequent commenter used and then after i realize it’s a flame message, i will update the all of the commenter’s email addresses in the database and inform him/her to not to use that email address any more.

  3. hehehe… The testing part is funny to view… although NICE IDEA dodo… thanks to skippy for the idea as well… well… nothing’s absolute anyway… are they? ^_^

  4. Great addition to my plugin! Would you mind sharing the code for that bit? I’m sure others would enjoy using it, and I can easily make it an option to enable or disable in commentauth.php.

    I’m working on a new version, after discovering the cause of some of the problems people had been experiencing. I’d love to include your improvements.

    1. i don’t know which bit you are talking about? i did not update your plugin code. btw, your valid_email function does not really work. i recommend this function.

      you are welcome to include any of my code. just a line comment of credit is fine.

      good job 🙂

  5. i think it’s kinda annoying to ask your regular commenters repeatedly moderate their own comments. so i added a little modification where your script tests if the commenter’s email already exists in the database or not. if it does, it will be automatically approved, otherwise an email with an approval link is sent to the user.

    So, did you or did you not modify the plugin?

    btw, your valid_email function does not really work.

    In the latest version (see below) I have removed that bit in favor of the is_email() function provided with WordPress.

    Anyway, I took your auto-approval idea, and wrapped it into a new version of my plugin, which is currently being beta tested. When I’ve confirmed that it’s working properly, I’ll officially release it.

    Cheers!

    1. yes i modified the script.. which is POSTED IN this post.. if you “click” the link to my code posted here. i modified wp-comments-post.php

      but since you already modified your plugin. then all is good.

Leave a Reply to dodo Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s