The attached patch provides the Captcha module with a two-part interface to other modules.

First, it defines two functions that other modules can call to present a captcha challenge. (For example, I have written an input filter module that encodes email addresses to protect them from spam harvesters; using this interface, it can present a captcha challenge before revealing the email address.) This interface consists of two functions: captcha_form(), which generates form items for the challenge, and captcha_test(), which tests the user's response.

Second, it defines a hook interface so that other modules can implement different captcha tests. (At present, the administrator selects which available test to use; in the future, this could be extended to, for example, permit visually impaired users to choose an alternative to the default image recognition challenge.) As an example, I have converted the arithmetic test from an earlier version of captcha.module into a captcha plug-in.

CommentFileSizeAuthor
#2 captcharith.module3.04 KBkps
#1 safemail.module4.75 KBkps
captcha-api.patch8.78 KBkps
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kps’s picture

FileSize
4.75 KB

Attached to this comment is an example of a module that uses the captcha interface defined in the above patch. This module encodes email addresses to protect them from spam harvesting. [Note: this example module is a work in progress.]

kps’s picture

FileSize
3.04 KB

Attached to this comment is a sample module that uses the hook interface defined in the patch above. This module is a plug-in captcha test that asks a simple arithmetic question; this makes the captcha module usable on systems without the GD image library. (This code is derived from an earlier version of captcha.module.)

arnabdotorg’s picture

Assigned: Unassigned » arnabdotorg
Status: Needs review » Active

Will be working on this for 4.7 onwards.

arnabdotorg’s picture

Status: Active » Fixed

I've added this functionality to the cvs version, pl. test and confirm.

Anonymous’s picture

Status: Fixed » Closed (fixed)