TRUE
);
$form->registerRule('recaptcha', 'callback', 'validate', 'CRM_Utils_ReCAPTCHA');
+ $form->addRule('g-recaptcha-response', ts('Please go back and complete the CAPTCHA at the bottom of this form.'), 'recaptcha');
if ($form->isSubmitted() && empty($form->_submitValues['g-recaptcha-response'])) {
$form->setElementError(
'g-recaptcha-response',
}
}
+ /**
+ * @param $value
+ * @param CRM_Core_Form $form
+ *
+ * @return mixed
+ */
+ public static function validate($value, $form) {
+ $resp = recaptcha_check_answer(CRM_Core_Config::singleton()->recaptchaPrivateKey,
+ $_SERVER['REMOTE_ADDR'],
+ $_POST['g-recaptcha-response']
+ );
+ return $resp->is_valid;
+ }
+
}