Skip to main content
Home
Nicholas Mangold

Main navigation

  • About
  • Projects
  • Blog
  • Contact
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Blog

Drupal Honeypot Module Documentation

This documentation explains how to install, configure, and test the Honeypot module in a Drupal site to protect forms from spam bots using hidden fields and time-based submission validation.


Table of Contents

  • πŸ“¦ Installation and Enabling with Composer and Drush
  • βš™οΈ Basic Configuration
  • 🧾 Enabling Honeypot for Webforms
  • πŸ” Permissions
  • βœ… Confirming Honeypot is Applied
  • πŸ§ͺ Testing Honeypot Blocking
    • πŸ” Test 1: Hidden Field Trigger
    • ⏱️ Test 2: Minimum Time Trigger
  • 🧯 Troubleshooting Steps
  • πŸ› οΈ Configuration Reference Table
  • βœ… Example Recommended Configuration
  • βš™οΈ Advanced Usage Notes
  • πŸ“Œ Summary

πŸ“¦ Installation and Enabling with Composer and Drush

Step 1: Require the Module with Composer

composer require drupal/honeypot

Step 2: Enable the Module Using Drush

drush en honeypot -y
drush pm:list | grep honeypot

βš™οΈ Basic Configuration

  1. Navigate to /admin/config/people/honeypot.
  2. Enable Protect all forms.
  3. Set Minimum time to e.g., 5 seconds.
  4. Optionally enable Log blocked form submissions.
  5. Save configuration.

🧾 Enabling Honeypot for Webforms

  1. Go to /admin/structure/webform/config.
  2. Scroll to Form settings.
  3. Enable Honeypot checkbox.
  4. Optionally configure Time limit and Element name.
  5. Save configuration.

πŸ” Permissions

Admins with bypass honeypot protection permission are not affected.

For testing: Use a logged-out or non-admin account.


βœ… Confirming Honeypot is Applied

  1. View the form as an anonymous user.
  2. Use browser dev tools (F12) to inspect the form.
  3. Look for:
    • A hidden honeypot_time field
    • A hidden honeypot text input (e.g., url)

πŸ§ͺ Testing Honeypot Blocking

πŸ” Test 1: Hidden Field Trigger

  1. Open a form as an anonymous user.
  2. Use developer tools to locate the honeypot field.
  3. Modify it:

    <input type="text" name="url" value="spamtest" />
  4. Wait the minimum time (e.g., 5 sec).
  5. Submit the form.
  6. Expect: Form is blocked; check logs if enabled.

⏱️ Test 2: Minimum Time Trigger

  1. Load the form and immediately submit within 1-2 seconds.
  2. Do not fill in the honeypot field.
  3. Expect: Submission blocked due to time restriction.

Using cURL:

curl -X POST https://example.com/form-path \
  -d "honeypot_time=1" \
  -d "field_name=value"

🧯 Troubleshooting Steps

  • βœ… Ensure Honeypot is enabled: drush pm:list | grep honeypot
  • πŸ”§ Check config at /admin/config/people/honeypot
  • πŸ‘€ Test with an anonymous user
  • πŸ“ Enable logging for blocked submissions
  • ⚠️ Look for conflicts with CAPTCHA/Webform Protect
  • 🧹 Run drush cr to clear cache

πŸ› οΈ Configuration Reference Table

SettingDescription
Enable Honeypot globallyApplies to all forms
Minimum timeMinimum seconds before valid submission
Honeypot element nameName of the hidden field (default: url)
Log blocked submissionsEnable logging in watchdog

βœ… Example Recommended Configuration

SettingValue
Enable Honeypot globallyβœ… Enabled
Minimum time5 seconds
Honeypot element nameurl
Log blocked submissionsβœ… Enabled (for debugging)

βš™οΈ Advanced Usage Notes

  • πŸ” Change the honeypot field name to something non-standard (e.g., contact_token) to evade bots targeting defaults.
  • πŸ§ͺ Temporarily enable logging to troubleshoot spam problems in /admin/reports/dblog.
  • ⚠️ Disable β€œProtect all forms” if you want to configure Honeypot only on specific content types or forms.

πŸ“Œ Summary

  • πŸ“¦ Install Honeypot via Composer and Drush
  • βš™οΈ Configure globally or per-form
  • πŸ§ͺ Test protection: hidden field and timing
  • πŸ› οΈ Log and monitor blocked attempts
  • βœ… Use recommended defaults and test with anonymous users
Tags
Drupal
About text formats

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Certifications

Badge for the Acquia Certified Developer - Drupal 7 certification
Badge for the Acquia Certified Front End Specialist - Drupal 7 certification
Badge for the Acquia Certified Back End Specialist - Drupal 7 certification
Badge for the Acquia Certified Grand Master - Drupal 7 certification

Recent Projects

Argonne National Laboratory

Screenshot of the Argonne National Laboratory homepage

Texas OAG

Screenshot of the Texas OAG homepage

Siemens PartQuest

Screenshot of the  Seimens PartQuest homepage

DODEA

Screenshot of the DODEA homepage
View more projects

Recent blog entries

  • Drupal Honeypot Module Documentation
  • How to use sudo with Touch ID on macOS Sonoma 14.x and above
  • Drush throws an "Access denied; you need (at least one of) the PROCESS privilege(s)" error message
  • Troubleshooting "ERROR 1227 (42000) at line 18: Access denied; you need (at least one of) the SUPER privilege(s) for this operation"
  • How to set up a local Drupal environment
View more blog entries
RSS feed
Powered by Drupal