0

In Drupal 7, I use the Commerce_Checkout_Redirect module which uses custom validation functions. It uses the following code.

// Use the username as order email.
// Email validation for the username form element
if (variable_get('commerce_checkout_redirect_username_as_order_email', FALSE)) {
  $form['name']['#title'] = t('Email');
  $form['actions']['continue_button']['#limit_validation_errors'] = array(array('name'));
  $form['actions']['continue_button']['#validate'][] = 'commerce_checkout_redirect_username_as_order_email_form_validate';
}

The validation function is the following.

function commerce_checkout_redirect_username_as_order_email_form_validate($form, &$form_state) {...}

The form ID is user_login, the reCaptcha is enabled for this form and it is shown, but it is ignored by the validation process when users submit the form.

How can I "force" the validation of the reCaptcha inside a custom validation function?

0

I figured out myself. The only thing i had to do is to add in #limit_validation_errors element another array with captcha_response. So the right syntax is

$form['actions']['continue_button']['#limit_validation_errors'] = array(array('name'),array('captcha_response'));

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.