[Wordpress] Tip I found to stop spammers from putting links/HTML in your comments

5 replies
  • WEB DESIGN
  • |
While looking for a post that I read once before about removing the option for comments on your blog, I stumbled across a different helpful tip.

Basically, it requires you to open up your theme's function.php file and add a single block of code. Once done, this will disallow any links and other HTML on your blog.

Here's the code (right-click and copy/paste):
PHP Code:
function plc_comment_post$incoming_comment ) {    $incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);    $incoming_comment['comment_content'] = str_replace"'"'''$incoming_comment['comment_content'] );    return( $incoming_comment );}function plc_comment_display$comment_to_display ) {    $comment_to_display str_replace'''"'"$comment_to_display );    return $comment_to_display;}add_filter('preprocess_comment''plc_comment_post'''1);add_filter('comment_text''plc_comment_display'''1);add_filter('comment_text_rss''plc_comment_display'''1);add_filter('comment_excerpt''plc_comment_display'''1); 
To access your functions.php file, you can do it easily by following these steps:

1.) Log in to your dashboard
2.) Scroll down, looking at the lefthand side until you see the "Appearance" section
3.)Click on "Editor"
4.) On the right, you will see a bunch of different .php pages. Scroll down until you see the "functions.php" mentioned above

Insert your code, save the file and that's it... no more free backlinks to spammers.

Of course, you could just use Akismet to block a majority of spam. However, there are still a lot of things that can get by, if not properly protected.

This way, even if your spam filters miss something, it will negate any benefit of spamming your blog until you have a chance to manually delete the entire comment.

Tip: If you aren't experienced or comfortable with playing around with your theme's core files, be sure to make a backup of the information you are changing. This is easily done by right-clicking the window with the code> Select All> Copy and then paste it into a notepad file.

You can also either backup your entire blog (which you should be doing frequently anyway) or use your favorite FTP program and copy the desired files into a folder on your desktop.
----------------------------------------------------------
Pretty simple stuff, but hopefully it will benefit someone.

Have a good weekend,
Mike
#found #stop #tip #wordpress

Trending Topics