This is a plugin that will block a spammer if he already has been tagged as a spammer. I use it together with the Akismet plugin. Akismet tags the spammer, and wp-denyhost prevents him from adding more comment spam.

If you have a CloudFlare account, the plugin can add spammers to the CloudFlare Block list

Core functionality

<br />
define('PS_DENYHOST_THRESHOLD', 3);<br />
function ps_denyhost() {<br />
    global $wpdb;</p>
<p>    $suspect = $this-&gt;get_IP();<br />
    $count = (int) $wpdb-&gt;get_var("SELECT COUNT(comment_ID) FROM $wpdb-&gt;comments WHERE comment_approved = 'spam' AND comment_author_IP = '$suspect'");</p>
<p>    if ($count &gt; PS_DENYHOST_THRESHOLD) {<br />
        exit;<br />
    }<br />
}<br />
add_action('init', 'ps_denyhost');<br />

Download / install: https://wordpress.org/extend/plugins/wp-denyhost/

Changelog

  • 1.2.1: added ps_wp_denyhost_admin_init, triggered by the admin_init hook
  • 1.2.0: Added support for CloudFlare Block list + removed wp deprecated code
  • 1.1.3: Fixed a minor bug
  • 1.1.2: Added response 403 Forbidden
  • 1.1.1: Added languages/wp-denyhost.pot
  • 1.1.0: Major rewrite. Added option page
  • 1.0.1: Replaced LIKE (‘%$suspect%’) with = ‘$suspect’ i.e. look for exact match
  • 1.0.0: Initial release