Description
The gform_state_is_valid_url filter allows developers to override the result of the source URL check in the honeypot state validation, which confirms a submission was sent from the same page the form was displayed on. When the check fails, the entry is marked as spam.
Usage
The following would apply to all forms.
add_filter( 'gform_state_is_valid_url', 'your_function_name', 10, 3 );
To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_state_is_valid_url_FORMID)
add_filter( 'gform_state_is_valid_url_5', 'your_function_name', 10, 3 );
Parameters
| Parameter | Type | Description |
|---|---|---|
| $is_valid | bool | Whether the request URL matches the URL the form was displayed on. |
| $url | string | The URL that was validated. |
| $form_id | integer | The ID of the form being validated. |
Examples
Skip the URL check for a form.
// Accept submissions for form 5 even when they are sent from a different URL than the one the form was displayed on.
add_filter( 'gform_state_is_valid_url_5', '__return_true' );
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Source Code
This filter is located in includes/form-display/state/class-state-handler.php.
Since
This filter was added in Gravity Forms [SINCE PLACEHOLDER]