# fluentform/4.3.21/app/Modules/Form/HoneyPot.php

Fluent Forms – Customizable Contact Forms, Survey, Quiz, &amp; Conversational Form Builder, version 4.3.21. 61 lines.

- Page: https://pluginprobe.com/plugins/fluentform/4.3.21/code/app/Modules/Form/HoneyPot.php
- Raw: https://pluginprobe.com/plugins/fluentform/4.3.21/raw/app/Modules/Form/HoneyPot.php
- Modified: 2022-10-27T17:40:16+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/fluentform/4.3.21/code/app/Modules/Form/HoneyPot.php#L10-L20`.

```php
<?php

namespace FluentForm\App\Modules\Form;

use FluentForm\Framework\Foundation\Application;
use FluentForm\Framework\Helpers\ArrayHelper;

class HoneyPot
{
    private $app;

    public function __construct(Application $application)
    {
        $this->app = $application;
    }

    public function renderHoneyPot($form)
    {
        if (!$this->isEnabled($form->id)) {
            return;
        }
        ?>
        <span style="display: none !important;"><input type="checkbox"
                name="<?php echo esc_attr($this->getFieldName($form->id)); ?>"
                value="1" style="display:none !important;" tabindex="-1"></span>
        <?php
    }

    public function verify($insertData, $requestData, $formId)
    {
        if (!$this->isEnabled($formId)) {
            return;
        }

        // Now verify
        if (ArrayHelper::get($requestData, $this->getFieldName($formId))) {
            // It's a bot! Block him
            wp_send_json(
                [
                    'errors' => 'Sorry! You can not submit this form at this moment!',
                ],
                422
            );
        }

        return;
    }

    public function isEnabled($formId = false)
    {
        $option = get_option('_fluentform_global_form_settings');
        $status = 'yes' == ArrayHelper::get($option, 'misc.honeypotStatus');
        return apply_filters('fluentform_honeypot_status', $status, $formId);
    }

    private function getFieldName($formId)
    {
        return apply_filters('fluentform_honeypot_name', 'item__' . $formId . '__fluent_checkme_', $formId);
    }
}

```
