Tips and Advice For Your Web Site
One of the worst things about the Internet is spam! If you’ve had a blog for more than 5 seconds, chances are your comments are constantly being flooded with spam comments. A really effective plugin is Akismet, but even it doesn’t eliminate spam – it only filters it.
A very simple way to keep a lot of comments from even making their way into your spam folder is to disable HTML tags in your comments. WordPress allows certain HTML tags in the comments section, and if you take a look at some of your spam, chances are it has HTML in it (like <strong> or <a?). This is because most spam is generated by bots or scripts.
To disable HTML tags in your comments, click on the “Editor” option listed under “Appearance” on the Dashboard. From there, select the functions.php file in your theme and insert the following code:
// This will occur when the comment is posted
function plc_comment_post( $incoming_comment ) {
// convert everything in a comment to display literally
$incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);
// the one exception is single quotes, which cannot be #039; because WordPress marks it as spam
$incoming_comment['comment_content'] = str_replace( “‘”, ‘'’, $incoming_comment['comment_content'] );
return( $incoming_comment );
}
// This will occur before a comment is displayed
function plc_comment_display( $comment_to_display ) {
// Put the single quotes back in
$comment_to_display = str_replace( ‘'’, “‘”, $comment_to_display );
return $comment_to_display;
Simple as that!
Starting a web site or trying to improve your online presence can be a daunting task for the casual computer user. Drawing from experience in the web hosting and ecommerce industry, The Common Hoster is your spot for technical resources, in an easy to understand format!
10 Responses to The Simplest Solution For Comment Spam
Tweets that mention The Simplest Solution For Comment Spam | The Common Hoster -- Topsy.com
November 11th, 2009 at 11:20 pm
[...] This post was mentioned on Twitter by anita santiago and Rich Blackburn, Terry A Shackelford. Terry A Shackelford said: RT @TheCommonHoster The Simplest Solution For Spam Comments http://bit.ly/3o078r #blog [...]
Paul Olyslager
November 12th, 2009 at 5:26 am
This is a really good tip. Maybe a good idea to make it optional in the wp dashboard or something. Another way to stop spam is using “honeypots”. These are hidden empty textfields in your form. As you said, most of the spam is generated by bots and these have the tendency to fill in every possible textfield they can find, including the hidden one. Just have a look if the honeypot field is empty (by javascript) before submitting the comment. If it is empty you can submit the comment, if it is filled in the chances are high that a spambot is involved. Soon you will find a post about this on my blog as well.
Hal
November 12th, 2009 at 6:23 am
This is good. I don’t know why html is allowed in comments – its not that important as far as I can see. Hopefully an option to disable comment html will be built in to future WP versions.
The only issue I see here is updating your theme, or changing a theme.
uberVU - social comments
November 12th, 2009 at 8:36 am
Social comments and analytics for this post…
This post was mentioned on Twitter by anitasantiago: RT @TheCommonHoster: The Simplest Solution For Comment Spam! http://bit.ly/3o078r #wordpress #blog #blogginh…
Mike McCready
November 12th, 2009 at 11:53 am
If you blog uses Wordpress, a tool that I would recommend is WP-Spamfree (http://wordpress.org/extend/plugins/wp-spamfree/) I use it and not only does it block comment SPAM, but also SPAM in my contact form. I’ve seen some sites use a CAPTCHA system, but I’ve never been a fan of them, but the plugin for Wordpress has worked great for me. Since I’ve installed the plugin, it has blocked 7,718 SPAM comments.
Heather Burlesci
November 12th, 2009 at 9:56 pm
Thank you for the tip. I actually tried to do this and it crashed my site. It gave me a syntax error on line 10. I’m new to the blogging world so maybe I just did something incorrectly. I removed the code and am going to try using one of the suggested Word Press plugins instead. If you happen to know why I got this error, feel free to pass it on.
@_e_bomb
November 15th, 2009 at 2:58 pm
Awesome! I am new to wordpress and have been noticing all the spam pile up. Cheers for the tip it came a the perfect time.
Peyton Stafford
November 16th, 2009 at 4:26 pm
I have several blogspot blogs. There is a settings option that requires all comments to be mediated. So far, I’ve been able to stay on top of these, manually.
How to avoid spam? | paul olyslager
November 24th, 2009 at 4:13 am
[...] as CMS. You can simply disable html tags in the comments textfield to avoid a great deal of spam. Jon Blackburn wrote an interesting piece about it, in where he explains how to disable the html [...]
Rich
November 24th, 2009 at 6:53 pm
Heather,
I’m sorry to have steered you wrong! Hopefully you were able to recover okay? Thanks for the comment.