I need to add a reCaptcha to my form; creating the form then adding the form ID to the reCaptcha settings did nothing.


I added the following form item to my form.

$form['captcha'] = array(
  '#type' => 'captcha',
  '#captcha_type' => 'recaptcha/reCAPTCHA',

It's pretty simple but it may trip some others up so hopefully this post saves someone time.

If you want to use some other captcha method you have installed on your site you can easily replace #captcha_type by going to /admin/config/people/captcha and using a tool like Firebug (or just view the page source and do some hunting) to view the options for the "Default challenge type" field on the captcha admin settings page. The values of each option is a valid option for the #captcha_type.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.