From its conception, the fundamental (ground) idea of the internet was the exchange of information through code snippets of a markup language. This is still the ground principle that moves the internet these days. There are, of course, a lot of other things you can do over the internet, but it all comes down to an exchange of information.
With this kind of freedom, it is not surprising, that people abuse this for their own benefit. Spam comments are a form of abusing this privilege.
The combination of the Drupal modules Honeypot and Antibot will ensure that your site is “almost” 100% protected from spam (at least the ones produced by robots).
Keep reading to learn how to Control Spam in Drupal with Honeypot and/or Antibot!
Step #1. – Install the Required Modules
- Open the terminal application of your computer.
- Place the cursor on the root of your Drupal installation.
composer require drupal/honeypot
composer require drupal/antibot
These two commands will install the codebase of both modules on your site.
Now it is time to enable them.
- Click Extend and look for the Honeypot and Antibot modules.
- Click Install.
Step #2. – Configure Honeypot
- Click Configuration > (Content authoring) > Honeypot configuration.
Honeypot uses two methods to detect whether a form is filled by a human being or a pre-written script (also known as robot or just bot):
- A hidden field (added by Honeypot). You can label this field whatever you want, but it makes sense to give it a unique “sticky” name, like “homepage” or “url” – this field is mandatory. Since people are not able to see this field, they also will not be able to fill it out. Bots will fall into the trap, and the form will be filed out; therefore detected as spam.
- The timestamp. If the form is filled out in less than 5 seconds, Honeypot will assume that it is being filled out by a robot, since people usually need more time to fill out a form on the internet. You can configure the time in seconds or leave this setting disabled at all if you prefer – with 0.
Notice: Pages containing honeypot-protected forms will NOT be cached.
- Check Log blocked form submissions.
Consider it some kind of “best practice” to get as much information as possible about what is happening within your Drupal system. Always use and check the logs.
- Leave the default “Honeypot default element” value.
- Leave the honeypot time limit of 5.
- Select the forms you wish to be protected by Honeypot
- Click Save configuration.
Step #3. – Honeypot Permissions
It is possible to bypass the Honeypot method by assigning the right permissions to certain roles.
- Click People > Permissions
- Locate the Honeypot permissions.
- Make the required changes.
- Scroll down and click Save permissions.
Step #4. – Configure Antibot
The code of Antibot runs statically, so page caching will be not be disabled on pages containing antibot-protected forms.
- Click Configuration > User Interface > Antibot.
You can configure the forms protected by Antibot on this interface. To protect multiple forms with the same base URL, add a ‘*’ character.
It is possible to control computer-generated spam either with the Drupal Honeypot, or the Drupal Antibot modules. You can also use a combination of both modules if you prefer on all forms or using one of them to particular forms on your site. It all depends on your needs and the ones of your web site..
Thanks for reading!