# wpremote/6.76/form_testing/handlers/gravity_form.php

The WP Remote WordPress Plugin, version 6.76. 48 lines.

- Page: https://pluginprobe.com/plugins/wpremote/6.76/code/form_testing/handlers/gravity_form.php
- Raw: https://pluginprobe.com/plugins/wpremote/6.76/raw/form_testing/handlers/gravity_form.php
- Modified: 2025-01-10T08:20:42+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/wpremote/6.76/code/form_testing/handlers/gravity_form.php#L10-L20`.

```php
<?php

if (!defined('ABSPATH')) exit;
if (!class_exists('BVGravityFormHandler')) :

class BVGravityFormHandler {
	private $form_id;
	private $bypass_params = array();

	public function __construct($form_id, $bypass_params) {
		$this->form_id = $form_id;
		$this->bypass_params = $bypass_params;
	}

	public function bypass() {
		if (array_key_exists('should_bypass_captcha', $this->bypass_params)) {
			$this->bypassCaptcha();
		}

		if (array_key_exists('should_bypass_email', $this->bypass_params)) {
			$this->bypassEmail();
		}
	}

	public function bypassCaptcha() {
		if ($this->form_id === null) {
			return;
		}

		add_filter('gform_pre_validation_' . $this->form_id, function($form) {
			foreach ($form['fields'] as &$field) {
				if ($field->type === 'captcha') {
					$field->visibility = 'hidden';
				}
			}
			return $form;
		}, PHP_INT_MAX);
	}

	public function bypassEmail() {
		add_filter('gform_pre_send_email', function ($email_data) {
			$email_data['abort_email'] = true;
			return $email_data;
		}, PHP_INT_MAX);
	}
}

endif;
```
