More comment flood

July 7th, 2004
WordPress Hack

Addendum from my previous post about comment flooding, this is what I would change the code in my wp-comments-post.php (between the comments, you should recognize the place):

// Simple flood-protection
$lasttime = $wpdb->get_var("SELECT comment_date FROM $tablecomments ORDER BY comment_date DESC LIMIT 1");
if (!empty($lasttime)) {
$time_lastcomment= mysql2date('U', $lasttime);
$time_newcomment= mysql2date('U', $now);
if (($time_newcomment - $time_lastcomment) < 300)
die( __('Sorry, this blog only allows a new comment once every 300 seconds. If you really want to write a comment, just wait a few and hit refresh on this page. Chances are you tried to add a comment about halfway between 0 and 300 seconds. Comment flooders are annoying. Thank you for being patient.') );

My own MySql server is messed up (because my mysql server is screwy AND in a different time zone than my web server, figure that) but it should work. If something breaks, I will try it on another server.




  1. Neerav (1 comments.) says:

    Nice idea Mark, any chance of releasing it as a plugin so users dont have to hack the wp-comments-post.php file directly?

  2. Jason (1 comments.) says:

    Thumbs up! I put my vote in for a plugin also, this would be great. Thanks for the wp hack Mark.


  1. [...] not eliminated the spam completely. I have found another suggestion on Weblog Tools – to increase the minimum time between posts. WordPress’ default settin [...]

  2. [...] another hack involves increasing the time between comment submissions, a method that works to stop spammers that “flood” your comments, but does nothing to [...]

Obviously Powered by WordPress. © 2003-2013

page counter