my customer want to add re-capcha of google in checkout of Woocommerce login form.

my code was check json connect with google OK. But form not check validate when submit. (show correct value from google but not effect with form)
how to fix code to validate re-capcha when submit with this form

my code:

function xrvel_login_recaptcha_open_url($url) {
if (function_exists('curl_init') && function_exists('curl_setopt') && function_exists('curl_exec')) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $response = curl_exec($ch);
} else {
    $response = file_get_contents($url);
    return trim($response);
        $captcha = $_POST['g-recaptcha-response'];
        $parameters = array(
        'secret' => '6LcN6BwUAAAAAH3x3dryOl2lm92Xvgr7tTnPEUPX',
        'response' => $captcha,
        'remoteip' => $_SERVER['REMOTE_ADDR'],

        $url = '' . http_build_query($parameters);
        $response = xrvel_login_recaptcha_open_url($url);
        $json_response = json_decode($response, true);
        if (isset($json_response['success']) && true !== $json_response['success']) {
            echo 'Not successfulllll';
            echo 'OK';
    } /*end is set*/
} /*end submit*/

Read more here: how to add re-capcha to login form in checkout woocommerce


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: