You are here

function recaptcha_v3_element_captcha_process_validate in reCAPTCHA v3 7

In case of failed recaptcha v3 token validation need to replace captcha validate callback in $element['#captcha_validate'] for displaying correct error message (otherwise will be executed replaced challenge validation with possible passed validation or wrong error message).

Parameters

$element:

$form_state:

$complete_form:

Return value

mixed

1 string reference to 'recaptcha_v3_element_captcha_process_validate'
recaptcha_v3_element_info_alter in ./recaptcha_v3.module
Place recaptcha v3 preprocess function at the beginning, so in this way it is possible to verify captcha and in case of fail, replace it to fallback captcha challenge.

File

./recaptcha_v3.module, line 152
Verifies if user is a human without necessity to solve a CAPTCHA.

Code

function recaptcha_v3_element_captcha_process_validate($element, &$form_state, $complete_form) {

  // Replacing validation callback only if correct next statements:
  // 1. user submit form
  // 2. in form exist recaptcha v3 token element
  if ($form_state['process_input'] && !empty($element['#recaptcha_v3_token'])) {
    $element['#captcha_validate'] = 'recaptcha_v3_captcha_validate';
  }
  return $element;
}