function recaptcha_v3_post_captcha_element_process in reCAPTCHA v3 8
Replace #captcha_validate by reCAPTCHA v3 validation function.
If real captcha type is reCAPTCHA v3 and it was not yet verify.
Parameters
array $element: The recaptcha v3 form element.
\Drupal\Core\Form\FormStateInterface $form_state: The recaptcha v3 form state.
array $complete_form: The recaptcha v3 complete form object.
Return value
mixed Set recaptcha v3 challenge if not already validated.
1 string reference to 'recaptcha_v3_post_captcha_element_process'
- recaptcha_v3_element_info_alter in ./
recaptcha_v3.module - Implements hook_element_info_alter().
File
- ./
recaptcha_v3.module, line 178 - Contains recaptcha_v3.module.
Code
function recaptcha_v3_post_captcha_element_process(array &$element, FormStateInterface $form_state, array &$complete_form) {
// If value exist, then form was submitted.
if ($form_state
->getTemporaryValue('recaptcha_v3_action_name')) {
$user_input = $form_state
->getUserInput();
// If value is empty, then fallback widget already used and no need to
// run recaptcha v3 validation.
if (!empty($user_input['is_recaptcha_v3'])) {
$element['#captcha_validate'] = 'recaptcha_v3_validate';
}
}
// Hide description for the recaptcha v3 captcha element.
if (!empty($element['captcha_widgets']['captcha_response']['#recaptcha_v3'])) {
unset($element['#description']);
}
return $element;
}