Just to further what Lee has said, look into what the module does out of the box, but I suspect that you're going to need to manage your form states on your own. Effectively what you're doing is a multistep form and I found the two documents helpful:

10. Multistep form - http://drupal.org/node/717750
Display a confirmation message before processing a form - http://drupal.org/node/470834

Basically I think the switch you'll need is to create yourself a session variable (e.g. $_SESSION['captcha_attempts']) and chose to load various other forms based on that.

HTH.
Anthony.

On 6:59 AM, Lee Rowlands wrote:
Hi Ben
I think captcha can be configured to run on any form, add mollom to the
mix and you get some advanced intelligence as to when you want the captcha
to be shown.

That said you should have a look at hook_form_alter
http://api.lullabot.com/hook_form_alter
You want to target when the form_id argument equals 'search_box_form'
You can add your handlers (submit/validation) to the form processing using

$form['#submit'] and $form['#validate'], the $form arg is passed by
reference.
Both of these are arrays, you should test that they exist first eg
if (is_array($form['#submit']) {
   array_unshift($form['#submit'], 'name_of_your_handler');
}
else {
   $form['#submit'] = array('name_of_your_handler');
}
If you use array_unshift, your handlers will run first.
You can then do form_state['redirect'] = 'your path' if needs be.
You can also add the captcha elements directly to the form if no session
var has been set
Ie in hook_form_alter, check the form_id is the search form, if it is and
there is no session var (tracking they've satisfied the captcha) then you
can add the captcha elements directly to the $form var (and your
submit/validate handlers). In your validate handler, test the captcha was
satisfied and then in your submit handler, set the session variable so the
next time the form is built, your form_alter hook doesn't add the captcha
again.
Hope this makes sense.
Lee

Reply via email to