0

I have a form I'm creating programmatically with a custom module, and I need to add the Google recaptcha to it. In the Google reCaptcha module's settings page (/admin/config/spam_protection/google_recaptcha/forms) I only see the login, register and comments forms and no way to add a custom form (like in the captcha module).

I googled as well as looked in the Google Captcha module's files and API file and can't find any hooks or info on how I can add the captcha element to a custom form. Any pointers would be appreciated!

1

You can use recaptcha module (https://www.drupal.org/project/recaptcha) and in captcha settings(admin/config/people/captcha) you can add your custom form's form_id and select the challenge type reCAPTCHA(from module recaptcha). This should work.

  • Interestingly, the captcha module doesn't work with the form_id if the custom form's function name is different. So if the custom function that creates the form is function foo_form() and the form id is set to bar_form inside the form function, I had to put foo_form in the captcha's settings. – longboardnode May 19 '17 at 3:27

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.