fbpx Getting the drupal captcha module to work | ComputerMinds Skip to main content

Getting the drupal captcha module to work

An article from ComputerMinds - Building with Drupal in the UK since 2005.
16th Jun 2007

Mike Dixon

Senior Mind

This article applies to the current dev release of both the captcha and the textimage module. It involves modifying captcha.inc file which is distributed with the textimage module - it is therefore only a temporary solution and should be treated with caution!

Step one - download and install.

To get the captcha module up and running you need the following modules




Step two - Turn on form store and form-collect

The form store and form collect modules allow you to build up a "store" of forms used on the site, to which you can then apply captchas.

Once you turn on form-collect, every new form you visit on the site will be added to the store. We don't want the list of forms to be too long and confusing so we just turn it on breifly and browse to the forms we know we want a captcha on (the contact form for example).

Step three - Configure the captcha points.

Go to the admin settings for the captcha module and click on the captcha points tab, in here you will want to select the forms which you wish to apply a captcha to. (to get more forms in this list see step 2)

Now go back to the first tab and select the type of captcha for each user role and each form. Most people just want a captcha on registration for anonymous users.

Step four - Configure textimage

Ideally you will have uploaded some ttf fonts to your site (we normally just use arial), and place them in a directory called fonts.

Goto the textimage admin page, click on the captcha display tab. Enter the path to your fonts (note do not use a preceding or trailing slash). You can play with the rest of the settings - we generally like to keep the font size down to around 14 and the other settings pretty low.

Step five - Configure user access (EASY ONE TO FORGET)

You will need to allow access to textimage to all user roles on the user access page - otherwise no one will be able to see your lovely captcha!!

Step six - Get hacking!

There are a number of known old issues with the captcha module. Firstly you will need to make a change to your session.inc file - as per this posting http://drupal.org/node/80615

This applies to release 5.x-1.2 of textimage. The captcha module has been altered to include a new hook _captcha. The captcha.inc file has not been updated to use this new hook. In addition a session variable (captcha) used in session.inc is clashing with a new session variable used in the new captcha module. I have attached our "fixed" version of the captcha.inc file - this needs to go into your textimage module dir (it might work - it might not!!)

Step seven - cross fingers

Hopefully that should work - and you should now have the captcha turned on and working.