-
-
Save andresclua/66b320e64857e0a3349411fbbefad4b4 to your computer and use it in GitHub Desktop.
recaptcha server php wp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('wp_ajax_nopriv_recaptcha_validate', 'recaptcha_validate'); | |
add_action('wp_ajax__loremrecaptcha_validate', 'recaptcha_validate'); | |
function recaptcha_validate() { | |
$recaptcha_client_token = $_REQUEST["google_access_token"]; | |
$SECRET_KEY = 'private token'; | |
$responseGoogleRecaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$SECRET_KEY."&response=".$recaptcha_client_token); | |
$responseGoogleRecaptcha = json_decode($responseGoogleRecaptcha,true); | |
// $other = $_REQUEST["per_page"]; | |
$response = [ | |
"state" => 'recaptcha_validate', | |
"client_token"=> $google_access_token, | |
"server_response" => $responseGoogleRecaptcha, | |
]; | |
echo json_encode($response); | |
/** | |
* Always finish with wp_die(); | |
*/ | |
wp_die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment