You are here

function _honeypot_honeypot_validate in Honeypot 2.0.x

Same name and namespace in other branches
  1. 8 honeypot.module \_honeypot_honeypot_validate()
  2. 6 honeypot.module \_honeypot_honeypot_validate()
  3. 7 honeypot.module \_honeypot_honeypot_validate()

Validate honeypot field.

1 string reference to '_honeypot_honeypot_validate'
honeypot_add_form_protection in ./honeypot.module
Form builder function to add different types of protection to forms.

File

./honeypot.module, line 205
Honeypot module, for deterring spam bots from completing Drupal forms.

Code

function _honeypot_honeypot_validate($element, FormStateInterface $form_state) {

  // Get the honeypot field value.
  $honeypot_value = $element['#value'];

  // Make sure it's empty.
  if (!empty($honeypot_value) || $honeypot_value == '0') {
    _honeypot_log($form_state
      ->getValue('form_id'), 'honeypot');
    $form_state
      ->setErrorByName('', t('There was a problem with your form submission. Please refresh the page and try again.'));
  }
}