Sunday, August 28, 2022
HomeWordPress DevelopmentWhy does reCAPTCHA v3 return 0 ? In customized AJAX registration type

Why does reCAPTCHA v3 return 0 ? In customized AJAX registration type


The key secret’s right, however it returns 0 and it would not appear to work correctly, what must be mounted or redone?

enter image description here

PHP code:
// add_recaptcha_api

add_action( ‘wp_enqueue_scripts’, ‘add_recaptcha_api’, 11 );

perform add_recaptcha_api() {
wp_deregister_script( ‘add_recaptcha_api’ );
wp_register_script( ‘add_recaptcha_api’, ‘https://www.google.com/recaptcha/api.js?render=6LdwamUbAAAAAJE-IEtIOT9VrbKSFi7U7Sfj62KR’);
wp_enqueue_script( ‘add_recaptcha_api’ );
}

perform registration_recaptcha(){

$recaptcha_url="https://www.google.com/recaptcha/api/siteverify";
$recaptcha_secret="secret";
$recaptcha_response = $_POST['recaptcha_response'];
$recaptcha = file_get_contents($recaptcha_url . '?secret=" . $recaptcha_secret . "&response=" . $recaptcha_response);
$recaptcha = json_decode($recaptcha);

if ($recaptcha->success == true && $recaptcha->rating >= 0.5 && $recaptcha->motion == “registration_recaptcha’) {

}

else

{
    

}

}

add_action( “wp_ajax_nopriv_registration_recaptcha”, “registration_recaptcha” );

Html code:

JS code:

enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments