public_key = $site_key; $this->private_key = $secret_key; // adds the captcha to the login form add_action( 'login_form', array( $this, 'captcha_display' ) ); // authenticate the captcha answer add_action( 'wp_authenticate_user', array( $this, 'validate_captcha_field' ), 10, 2 ); } /** Output the ACL_gcaptcha form field. */ public function captcha_display() { ?>
ERROR: Please confirm you are not a robot' ); } return $user; } /** * Send a GET request to verify captcha challenge * * @return bool */ public static function captcha_verification() { $response = isset( $_POST['g-recaptcha-response'] ) ? esc_attr( $_POST['g-recaptcha-response'] ) : ''; $remote_ip = $_SERVER["REMOTE_ADDR"]; // make a GET request to the Google reCAPTCHA Server $g_page = unserialize(get_option('Admin_custome_login_gcaptcha')); $site_key = $g_page['site_key']; $secret_key = $g_page['secret_key']; $request = wp_remote_get( 'https://www.google.com/recaptcha/api/siteverify?secret=' . $secret_key . '&response=' . $response . '&remoteip=' . $remote_ip ); // get the request response body $response_body = wp_remote_retrieve_body( $request ); $result = json_decode( $response_body, true ); return $result['success']; } } new ACL_gcaptcha_Login_Form(); ?>