function google_captcha_captcha_validation in Google Captcha 7
CAPTCHA Callback; Validates the google captcha code.
1 string reference to 'google_captcha_captcha_validation'
- google_captcha_captcha in ./
google_captcha.module - Implements hook_captcha().
File
- ./
google_captcha.module, line 75 - Verifies if user is a human without necessity to solve a CAPTCHA.
Code
function google_captcha_captcha_validation($solution, $response, $element, $form_state) {
$google_captcha_private_key = variable_get('google_captcha_private_key', FALSE);
if (empty($_POST["g-recaptcha-response"]) || empty($google_captcha_private_key) || !_google_captcha_load_library()) {
return FALSE;
}
$reCaptcha = new ReCaptcha($google_captcha_private_key);
$resp = $reCaptcha
->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
return $resp != null && $resp->success;
}