Title: Avoiding Comment Moderation
Last modified: August 18, 2016

---

# Avoiding Comment Moderation

 *  [stevem](https://wordpress.org/support/users/stevem/)
 * (@stevem)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/)
 * Comment moderation of common spam words can get tedious at times. Basically I
   want WordPress to ignore comments with a spam word in, but allow others through.
   I can do this by modifying wp-comments-post.php by adding
    `if ($approved) {`
   before `$wpdb->query("INSERT INTO $tablecomments` and adding `}` after `$comment_ID
   = $wpdb->get_var('SELECT last_insert_id()');` and finally commenting out the 
   lines `if (!$approved) { wp_notify_moderator($comment_ID); } But I feel this 
   would be better done by using a plugin. But I can’t see how to do that to prevent
   a comment being inserted into the database. Any ideas?

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Mark Jaquith](https://wordpress.org/support/users/markjaquith/)
 * (@markjaquith)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/#post-104576)
 * Basically, any plugin that automatically deletes or puts in moderation a comment
   does so by changing the comment that has already been in the data base (for a
   split second).
    Unfortunately with WordPress 1.2, you cannot prevent the “Comment
   posted” e-mail from going out just by using a plugin. This has been remedied 
   in WordPress 1.3 Using WordPress 1.3, it would be trivial to make a plugin that
   deletes comments that are hit by the blacklist. I’m not sure it’s a great idea,
   unless you really really trust your blacklist, but it could be done.
 *  [mike3k](https://wordpress.org/support/users/mike3k/)
 * (@mike3k)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/#post-104837)
 * Yesterday I got hit with a lot of comment spam and got tired of having to delete
   each one of them, so I came up with this patch.
    In wp-comments-post.php, add
   the following code `$words = array ( "golimar.com", "levitra", "tramadol", "cialis","
   fioricet", "phentermine", "viagra", ); foreach ($words as $word) { $word = trim(
   $word); $pattern = "#$word#i"; if (preg_match($pattern,$comment) || preg_match(
   $pattern,$url)) { die ("You are not allowed to post comments, spammer."); } Before
   the line:  $wpdb->query("INSERT INTO $tablecomments  (comment_post_ID, comment_author,
   comment_author_email, comment_author_url,  How can I convert this to a plugin?
 *  [mike3k](https://wordpress.org/support/users/mike3k/)
 * (@mike3k)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/#post-104838)
 * P.S. you can change that array as necessary to list any words that only appear
   in spam, such as domain names.
 *  [charle97](https://wordpress.org/support/users/charle97/)
 * (@charle97)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/#post-104844)
 * you can probably model your plugin after laughinglizard’s [three strikes plugin](http://weblogtoolscollection.com/archives/2004/09/24/three-strikes-and-out-damned-spam-out-i-say/).
   it’s the only comment spam plugin that i’ve seen to prevent spam comments from
   hitting the database.
 *  Thread Starter [stevem](https://wordpress.org/support/users/stevem/)
 * (@stevem)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/#post-104907)
 * Great! Three strikes looks like just the sort of thing I am after. The URL decode
   function in it is an excellent idea. Will give it a go.
 *  [poons15](https://wordpress.org/support/users/poons15/)
 * (@poons15)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/#post-104978)
 * Three strikes did not work for me. For some reason it changed my comment submit
   button link to go to fbi.gov. I had to deactivate the plugin. I like the code
   that was provided above by Mike3k.
    That might be something that I might just
   go ahead and add. Comment spam sucks!
 *  Thread Starter [stevem](https://wordpress.org/support/users/stevem/)
 * (@stevem)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/#post-105006)
 * It works well for me. The fbi.gov (which you can change in the threestrikes file)
   should only be triggered when it thinks the comment is spam
 *  [mike3k](https://wordpress.org/support/users/mike3k/)
 * (@mike3k)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/#post-105066)
 * I’ve converted it to a plugin, which can be downloaded [here](http://www.mcdevzone.com/files/killspam.phps).
 *  Anonymous
 * [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/#post-105073)
 * Cool plugin!
    Just a suggestion, would it be possible to integrate the plugin
   with WP Blacklist such that $spamwords automatically uses the ones already in
   WP Blacklist (or the ones already specified in WP’s built-in spamword list?) 
   This would save the effort of having to maintain 2-3 spamword blacklists.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Avoiding Comment Moderation’ is closed to new replies.

 * 9 replies
 * 6 participants
 * Last reply from: Anonymous
 * Last activity: [21 years, 7 months ago](https://wordpress.org/support/topic/avoiding-comment-moderation/#post-105073)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
