Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Add reCaptcha to your Drupal 7 forms programatically

Parent Feed: 

If you want to add Google's reCaptcha (https://www.google.com/recaptcha/intro/index.html) to your Drupal 7 forms programmatically you need to follow these two steps:

1) Install and enable captcha (https://www.drupal.org/project/captcha) and recaptcha (https://www.drupal.org/project/recaptcha) modules. The best way to do this is to use drush: drush en -y recaptcha

2) Add this snippet to any Drupal form's code you wish to have this captcha on:

  1. $form['captcha'] = array(

  2. '#type' => 'captcha',

  3. '#captcha_type' => 'recaptcha/reCAPTCHA',

  4. );

And you're done! I hope from now on, spam bots will bother you less.

Don't forget to share this little tip if you like it!

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web