[Drupal] How to use Recaptcha module?

| | 2 min read

There are a lot of pragmatically created crawlers today. If is a website is open for registration these crawlers can maliciously faux accounts of their own. In such cases, we usually use CAPTCHA. CAPTCHA is like a protective shield for our website from those bots.

Recaptcha is one of its type. It is the one which is in demand at its peak. Recaptcha is an image which may contain letters, characters, or numbers. And its advantage is that bots wont make these correct. By doing so, we can reduce the fake registrations to our site.

In drupal, we have a module as recaptcha. All we want is to download and install the same. Either use it using drush or through web.

I love using drush. From the url you can the recptcha module, https://www.drupal.org/project/recaptcha.

The word after project/ is used in drush, here it is recaptcha, so it would look like,

drush en recaptcha -y;

Usually we use recaptcha in a form, to integrate recaptcha in a form,

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

Here we have a form element as CAPTCHA, specify the type as CAPTCHA, also the type of CAPTCHA we use. If we didn't specify any CAPTCHA it will automatically load the math CAPTCHA.

We haven't done yet. We need to get the private and public key for the recaptcha module to work. From this url,http://www.google.com/recaptcha/intro/index.html. To the right, there is a button, Get reCaptcha.

Register the url in which the form is used. For example, we are using recptcha in the login form of example.com,

So register the url at domains, we can use the same public and private key for as many sites as possible, just input those url's a line after the other. Enter the description in label textbox and register. You have done.

Still some work left, we need to do some configuration for captcha. Here admin/config/people/captcha/recaptcha, enter the public and private key. Now you are done.

When I had a requirement to include a recaptcha in a custom form, all I did is just install the recptcha module. This module came handy at that moment. No much coding required. https://www.drupal.org/node/151588, The above url provide a lot about the configuration and its settings. Hope this would help some to configure the module.