Viewing 2 replies - 1 through 2 (of 2 total)
  • I have the same problem, i now only add it for registration.

    • This reply was modified 4 years, 7 months ago by Linksquest.

    Add the following code to the function:

    /*=Add ReCaptcha to registration form
    /****************************************************/
    function oley_add_recaptcha_field() {
        ?>
    	<script src="https://www.google.com/recaptcha/api.js" async defer></script>
        <p>
            <label for="recaptcha"><br />
                <div class="g-recaptcha" data-sitekey="6LeMTZ8UAAAAADPQsTUpY6Vu-AIuaHYpaXtW4BjE"></div>
            </label>
        </p>
        <?php
    }
    add_action( 'register_form', 'oley_add_recaptcha_field' );
    
    function oley_validate_recaptcha_field( $errors, $sanitized_user_login, $user_email ) {
    
        if ( empty( $_POST['g-recaptcha-response'] ) ) {
            $errors->add( 'recaptcha_error', __( '<strong>ERROR</strong>: Please verify that you are not a robot.', 'oleymediagroup' ) );
        }
    
        return $errors;
    }
    add_filter( 'registration_errors', 'oley_validate_recaptcha_field', 10, 3 );
    
    

    Note that you must enter your site key

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Google Capcha in Login With Ajax’ is closed to new replies.