Description
Modify the form object before saving on the Form Settings page. Useful for saving custom settings added via the gform_form_settings filter.
Usage
add_filter( 'gform_form_settings_before_save', 'my_custom_function' );
Parameters
Parameter | Type | Description |
---|---|---|
$form | Form Object | The current form object being edited. |
Examples
This example demonstrates how you can save custom settings added via the gform_form_settings filter to the form object using the gform_form_settings_before_save filter.
// Add a custom form setting
add_filter('gform_form_settings', 'my_custom_form_setting', 10, 2);
function my_custom_form_setting($settings, $form) {
$settings['standard']['my_custom_setting'] = '
<tr>
<th><label for="my_custom_setting">My Custom Label</label></th>
<td><input value="' . rgar($form, 'my_custom_setting') . '" name="my_custom_setting" /></td>
</tr>';
return $settings;
}
// Save the custom form setting
add_filter('gform_form_settings_before_save', 'save_my_custom_form_setting');
function save_my_custom_form_setting($form) {
$form['my_custom_setting'] = rgpost('my_custom_setting');
return $form;
}
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 form_settings.php.