function wppb_validate_captcha_response($publickey, $privatekey) { if (isset($_POST['g-recaptcha-response'])) { $recaptcha_response_field = $_POST['g-recaptcha-response']; } else { $recaptcha_response_field = ''; } $resp = wppb_recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_response_field); if (!empty($_POST)) { return !$resp->is_valid ? false : true; } }
function wppb_add_captcha_error_message() { $reCaptchaSettings = get_option('reCaptchaSettings', 'not_found'); if ($reCaptchaSettings == 'not_found') { $publickey = ""; $privatekey = ""; } else { $publickey = trim($reCaptchaSettings['publicKey']); $privatekey = trim($reCaptchaSettings['privateKey']); } $resp = wppb_recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!empty($_POST)) { if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly if ($publickey != '' || $publickey != null || $privatekey != '' || $privatekey != null) { //make sure the user doesn't get a double error on registration return __("The reCAPTCHA wasn't entered correctly. Go back and try it again!", "profilebuilder"); } } else { // Your code here to handle a successful verification return ''; } } }