use \Bitrix\Main\Mail\Event;
AddEventHandler('form', 'onAfterResultAdd', 'my_onAfterResultAddUpdate');
function my_onAfterResultAddUpdate($WEB_FORM_ID, $RESULT_ID)
{
/*capcha */
if (isset($_POST['recaptcha_response'])) {
$recaptcha_key = 'секретный ключ';
$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
$recaptcha_params = [
'secret' => $recaptcha_key,
'response' => $_POST['recaptcha_response'],
'remoteip' => $_SERVER['REMOTE_ADDR'],
];
$ch = curl_init($recaptcha_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $recaptcha_params);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
if (!empty($response)) {
$decoded_response = json_decode($response);
}
$recaptcha_success = false;
//dbg2f($decoded_response, 'responce');
if ($decoded_response && $decoded_response->score > 0) {
$recaptcha_success = $decoded_response->score;
// ???????????? ?????? ?????, ??????? ???????? ??????
} else {
// ??????????? ????????, ???? ???????????? ???????? ?????
}
}
/*capcha */
/*&& $recaptcha_success > 0.5*/
if ($WEB_FORM_ID == 'КАК ТУТ ПРОВЕРИТЬ НА ФОРМУ РЕГИСТРАЦИИ' && $recaptcha_success > 0.5){
}
}