Honeypot isn't protecting my Entity Registration module's registration forms. I tried a custom module (created a customized.info and customized.module), but it's not doing anything.

Am I doing something wrong?

<?php
function hook_form_registration_form_alter(&$form, &$form_state, $form_id) {
honeypot_add_form_protection($form, $form_state, array('honeypot', 'time_restriction'));
}

Comments

geerlingguy’s picture

Status: Active » Postponed (maintainer needs more info)

If the name of your custom module is 'customized', then the function should be like:

function customized_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'form_id_you_are_interested_in') {
    honeypot_add_form_protection($form, $form_state, array('honeypot', 'time_restriction'));
  }
}

You can see the form id by going to the form itself, viewing the page source, and finding the "form_id" value in the source.

jessmiller’s picture

Thanks geerlingguy. I changed the code in my custom module as suggested, cleared the cache, made sure my custom module is enabled, but honeypot still isn't showing up on the form (in chrome developer tools, i searched the html for "honey" with no results)

<?php
function customized_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'registration_form') {
    honeypot_add_form_protection($form, $form_state, array('honeypot', 'time_restriction'));
  }
}
geerlingguy’s picture

Another question - are you logged in as the site administrator? The admin automatically bypasses honeypot protection, so it won't show up at all. Additionally, if your user account has a role that bypasses honeypot protection (on the permissions page), then it wont' show up either.

jessmiller’s picture

Yes! That's it. Logged out, and honeypot is right there in the source html. Thanks!

geerlingguy’s picture

Category: task » support
Status: Postponed (maintainer needs more info) » Closed (works as designed)

Great! I'm glad I could help :)