Version 3.2.2: Peter’s Custom Anti-Spam Image Plugin for WordPress

First published on November 17, 2006

Other variations


I really dislike spambot posts. You know, the ones that advertise jumbled links. There are quite a few plugins to combat blog comment spam, and they usually come in two varieties: one that filters and identifies spam posts and another that forces users to identify a random word displayed as an image in order to block spambots that cannot read your image. You can use both varieties of spam filters in tandem. There’s even a third option where you can rename your comment and trackback files in order to reduce the server load from spambots.

At any rate, I’ve developed my own anti-spam image plugin. You can test it by leaving a comment on this site.

My plugin is based on Anti-Spam Image by Krazy Nio (which I can no longer locate) and I also used some code that I learned from what I like to call the best PHP tutorial ever.


  • Toggle whether registered users need to enter the word
  • Random font display
  • No cookies required
  • No JavaScript required
  • Auto-generated audio for visually impaired users
  • Easy-to-read
  • No mapping of words from the code — words are used once or removed after 24 hours
  • Reminder of what was entered if you get the word wrong
  • Selective blocking of trackbacks, pingbacks
  • Easy to translate


  • Purposely no obscuring techniques so that the anti-spam word is easy to read
  • The more people who use this plugin, the more motivation for spambots to target it


  • GD Library and FreeType Library (There’s a diagnostic page at Manage > Custom Anti-Spam in your WordPress admin panel to tell you whether you have them installed. If needed, just ask your web host to install them!)
  • WordPress 3.2 or higher

That being said…

Version 3.2.2 of Peter’s Custom Anti-Spam Image Plugin for WordPress [February 8, 2014: Minor code cleanup (thanks koc!)]

Download Version 3.2.2


  • ru_RU translation by koc
  • Patrik ┼Żec (PATWIST)

View all past versions

2.0+ releases:
Unzip the entire folder custom-anti-spam to your plugins directory, so that the path is wp-content/plugins/custom-anti-spam/. Then activate the plugin via your WordPress admin section. The plugin should work directly “out of the box”, but all settings can be customized in the Settings > Custom anti-spam page in your WordPress control panel (3.1.0 and up) or in the plugin file itself (3.0.7 and lower). If you are upgrading from a previous release, de-activate that release first.

Here’s a brief outline on how to do the manual insert.

Check the archive page for pre-2.0 instructions.

Common issues

– Keep the words short (7-8 letters max).
– Make sure you upload the .ttf files in binary, not ASCII format.
– After initializing the plugin, log out of WordPress to test it. By default registered users don’t have to enter the anti-spam word (although this can be changed in the settings at the top of the plugin file).
– If you have a funky theme, you might want to tweak the code to display optimally. For example, with the In Business theme, try copying and pasting the default comments.php code over In Business’s comments.php; for the Blix theme, check this out.
– Check the diagnostic page at Settings > Custom Anti-Spam in your WordPress admin panel to see any possible problems.
– Getting a database error after installing? You might have to create the tables manually. See this forum post for details.
– Are you using WordPress 2.6 or higher and did you move wp-config.php or the wp-content folder to a non-default location? Upgrade to version 3.0.7 of the plugin or higher and configure the $cas_wpconfig setting in the plugin file itself.
– If you are using a caching plugin that does not allow specific parts of a page to be uncached, set the option “Use JavaScript to generate anti-spam code” to “Yes”.

Plugin upkeep

For best continuing anti-spam performance:

– Change up the anti-spam words every once in a while
– Change up the fonts every once in a while


Please make all comments and questions regarding the plugin in the forum! The number of comments were getting to be a bit hard to follow, so the forum should help with organization. Old comments are on the history page.

Note: you can still test the plugin using the comment form on this page. However, all comments are deleted once daily.

Forum for Peter’s Custom Anti-Spam Image

Forum/Topic Started Last post Posts

Peter’s Custom Anti-Spam for WordPress

Some suggestions for markup validation and Russian translation

February 5, 2014
7:23 am by

February 5, 2014
7:51 am by


Peter’s Custom Anti-Spam for WordPress

WP 2.9.2 + anti-spam 3.2.0 + install manual = no images,

September 24, 2013
10:35 pm by

September 25, 2013
1:54 pm by


Speak your mind

This form is only for testing the plugin (all comments on this page are deleted once daily). Please make all comments and questions regarding the plugin in the forum!

To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word