# contact-forms/2.2.4/classes/Validation/Captcha2b.php

Contact Forms by Cimatti, version 2.2.4. 55 lines.

- Page: https://pluginprobe.com/plugins/contact-forms/2.2.4/code/classes/Validation/Captcha2b.php
- Raw: https://pluginprobe.com/plugins/contact-forms/2.2.4/raw/classes/Validation/Captcha2b.php
- Modified: 2026-04-08T09:49:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/contact-forms/2.2.4/code/classes/Validation/Captcha2b.php#L10-L20`.

```php
<?php
/**
 * reCAPTCHA v2 Validation
 *
 * @package Contact Forms
 */

// phpcs:disable WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput -- Server-side CAPTCHA validation requires POST data

class AccuaForm_Validation_Captcha2b extends Validation {
	protected $message = 'Error: The reCAPTCHA response provided was incorrect. Please retry.';
	protected $privateKey;

	public function isValid( $value ) {
		if ( ! isset( $_POST['g-recaptcha-response'] ) ) {
			return false;
		}

		$response = stripslashes_deep( $_POST['g-recaptcha-response'] );

		if ( '' === $response ) {
			return false;
		}

		$verify_url = 'https://www.google.com/recaptcha/api/siteverify';

		$verify_data = array(
			'secret'   => $this->privateKey,
			'response' => $response,
			'remoteip' => isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '',
		);

		$response_obj = wp_remote_post(
			$verify_url,
			array(
				'body'    => $verify_data,
				'timeout' => 20,
			)
		);

		if ( is_wp_error( $response_obj ) ) {
			return false;
		}

		$body   = wp_remote_retrieve_body( $response_obj );
		$result = json_decode( $body, true );

		if ( ! empty( $result['success'] ) ) {
			return true;
		}

		return false;
	}
}

```
