if ( empty( $_POST['g-recaptcha-response'] ) ){
// User didn't check recaptcha, handle the error
} else {
$params = http_build_query( array(
'secret' => $secret,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $some_ip
) );
$captcha_resposne = false;
if ( 200 == $response['response']['code'] ) {
$captcha_resposne = json_decode( $response['body'], true );
// missing-input-secret The secret parameter is missing.
// invalid-input-secret The secret parameter is invalid or malformed.
// missing-input-response The response parameter is missing.
// invalid-input-response The response parameter is invalid or malformed.
}
// If captcha respsonse is true we sign them on
if ( $captcha_resposne['success'] === true ){
// handle the success
} else {
// handle the failure
}
}