Creating nodes can take a long time. That is why for one specific part of my site, I have created my own custom form. The problem is, I want to use the captcha plugin so I don't have to get another separate module for that.

How can I use the Captcha module PROGRAMATICALLY so that I don't need a separate libary?

1 Answer 1


From looking at the code in the Captcha module, it looks like Captcha defines a new form element.

So an example would look like:

$form['name'] = array(
  '#type' => 'textfield',
  '#title' => t('Name'),
$form['captcha'] = array(
  '#type' => 'captcha',
  '#captcha_type' => 'captcha/Math',

Where captcha/Math is the module that provides a type of captcha, followed by the type of captcha to use.

  • and how can I set the refresh button? Jun 12, 2017 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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