Plugins

The Way I Deal with Spam Comments

Oleh takien• 4 Komentar Arsip
Spammer

Spammer

There are so many WordPress plugins tagged spam published in WordPress plugins directory. Most of the plugins is to combat spam comment in WordPress blog. However, I am not use one of those plugins, because of several reasons:  they are captcha based (eg. re-Captcha) and they are using API (eg. Akismet). In my experience, using both type of anti spam could decrease my blog performance.

For that reason I have a few tips for you to combat spam without sacrificing your web performance:

1. Never install any anti spam plugins that come with captcha, API, or remote database access.

2. Some plugins will count your spam, haha… it’s funny. Do not install such plugins.

3. Ensure you have these setting in wp-admin/options-discussion.php

– An administrator must always approve the comment ( This should be ON)
– Comment author must have a previously approved comment (This should be OFF)

4.  Use built in WordPress feature, blacklist comment. See figure below:

Comment blacklist

Comment blacklist

6. Delete spam comment automatically. To do this I have written a little plugin named Delete Spam Hourly.

Here is the code:

[php title=Delete Spam Hourly]

/*
Plugin Name: Delete Spam Hourly
Plugin URI: /
Description: Automatically delete blacklisted comment/spam every hour.
Author: takien
Version: 0.1
Author URI: /
*/

register_activation_hook(FILE, ‘activate_delete_spam_hourly’); add_action(‘delete_spam_hourly_event’, ‘delete_spam_hourly’);

function activate_delete_spam_hourly() { wp_schedule_event(time(), ‘hourly’, ‘delete_spam_hourly_event’); }

function delete_spam_hourly() { $pending = ‘0’; $spam = ‘spam’;

global $wpdb; $comment_ids = $wpdb->get_col( “SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = ‘$pending’ OR comment_approved = ‘$spam’” );

foreach ($comment_ids as $comment_id){ $comment = get_comment($comment_id, ‘ARRAY_A’); if(wp_blacklist_check($comment[‘comment_author’],$comment[‘comment_author_email’],$comment[‘comment_author_url’],$comment[‘comment_content’], $comment[‘comment_author_IP’],$comment[‘comment_agent’])){ wp_delete_comment($comment_id); } } }

[/php]

Tulisan ini sudah berumur: 15 tahun 10 bulan 2 hari. Informasi di dalamnya mungkin sudah tidak relevan, tapi nilai historisnya sangat berharga, terutama bagi saya sebagai penulisnya.

Tag Terkait:

Komentar (4)

Arsip Statis
jejen
pertamax……….
Brian Gottier
I’ve been using Defensio, but I just don’t want to deal with the spam comments que, and most spams are easily targeted. I’m going to try your plugin. It looks like it will work perfectly. Thanks!
Presiden IDIOTNESIA
Lhah, sama aja Mastah, make plugins juga, cuman Plugins punya Mastah Takien gak pake capcay ama api.. I will try this at home.. 😀 *ada list backlist keyword gak Mastah?
David
I want to thank you for your little plugin. I discovered that over 80% of my spam was from yahoo.com and gmail.com. I blacklisted both domains and presto – huge drop in spam comments BUT huge spam folder. Your plugin lets me check my site every week or so now instead of daily. One question – how could I change the plugin to delete spam daily?  With gratitude David