2

I'm making a custom form (fields are added by using drupal_render), but since I have Honeypot enabled for all my web forms, when I submit a form, I get the following message:

There was a problem with your form submission. Please wait X seconds and try again.

That's because Honeypot markup isn't being included in my custom form.

I have two options:

  1. Disable Honeypot for this form (not possible through module settings from Drupal administration menu). How can I add an exception?
  2. Enable Honeypot manually (with drupal_renders I guess).

Honeypot docs is so poor, so I also have tried to add Honeypot markup manually in this way: <?php print drupal_render($form['honeypot_time']); ?> <?php print drupal_render($form['url']); ?>

It adds the markup actually, but it isn't fixing yet.

7

According to the module documentation, you can do this:

If you want to add honeypot to your own forms, or to any form through your own module's hook_form_alter's, you can simply place the following function call inside your form builder function (or inside a hook_form_alter):

<?php
  honeypot_add_form_protection($form, $form_state, array('honeypot', 'time_restriction'));
?>

Note that you can enable or disable either the honeypot field, or the time restriction on the form by including or not including the option in the array.

You can also use Honeypot's API to modify the time delay for forms, add or remove protections for certain forms, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.