Description
The filter gform_form_settings_initial_values
allows the initial values that will be populated into the form settings to be overridden.
Usage
The filter which would run for all forms would be used like so:
add_filter( 'gform_form_settings_initial_values', 'your_function_name', 10, 2 );
Parameters
- $initial_values array
An associative array of setting names and their initial values. - $form Form Object
The form currently being edited.
Examples
1. Enable Honeypot
add_filter( 'gform_form_settings_initial_values', function( $initial_values, $form ) {
$initial_values['enableHoneypot'] = true;
return $initial_values;
}, 10, 2 );
Placement
This code should be placed in the functions.php file of your active theme or a custom functions plugin.
Since
This filter was added in Gravity Forms v2.5.
Source Code
This filter is located in GFFormSettings::get_initial_values() in form_settings.php.