function riddler_captcha_validate in Captcha Riddler 8
Same name and namespace in other branches
- 6 riddler.module \riddler_captcha_validate()
- 7 riddler.module \riddler_captcha_validate()
Custom validation for Riddler.
1 string reference to 'riddler_captcha_validate'
- riddler_captcha in ./
riddler.module - Implements hook_captcha().
File
- ./
riddler.module, line 65
Code
function riddler_captcha_validate($solution, $captcha_response, $element, $form_state) {
// There can be multiple possible answers, so explode solution.
$solutions = explode(',', $solution);
// Remove any stray spaces.
$solutions = array_map('trim', $solutions);
$isolutions = array_map('strtolower', $solutions);
switch (\Drupal::config('captcha.settings')
->get('default_validation')) {
case CAPTCHA_DEFAULT_VALIDATION_CASE_SENSITIVE:
return in_array($captcha_response, $solutions);
break;
case CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE:
return in_array(strtolower($captcha_response), $isolutions);
break;
}
// Just in case.
return FALSE;
}