Description
The gform_notification_settings_fields filter is used to customize the available settings on the Notification configuration page.
Usage
The filter which runs for all would be used like so:
add_filter( 'gform_notification_settings_fields', 'your_function_name', 10, 3 );
You can also target a specific form by adding the form id after the hook name.
add_filter( 'gform_notification_settings_fields_6', 'your_function_name', 10, 3 );
Parameters
-
$fields array
The Form Settings fields. See the Settings API for details about how the fields are defined.
-
$notification Notification Object
The meta for the form notification being viewed/edited.
-
$form Form Object
The current form.
Examples
Add a new field
This example would add a hidden field to the notification configuration page.
add_filter( 'gform_notification_settings_fields', function ( $fields, $notification, $form ) {
$fields[0]['fields'][] = array( 'type' => 'hidden', 'name' => 'my_custom_hidden_field' );
return $fields;
}, 10, 3 );
Replace From Email default value when adding a new notification
This example would apply only to new notifications added from the Notifications list page. The default Admin Notification settings can’t be filtered.
add_filter( 'gform_notification_settings_fields', function ( $fields, $notification, $form ) {
foreach ( $fields[0]['fields'] as &$field ) {
if ( rgar( $field, 'name' ) !== 'from' ) {
continue;
}
$field['default_value'] = str_replace( '{admin_email}', '[email protected]', $field['default_value'] );
}
return $fields;
}, 10, 3 );
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 GFNotification::settings_fields() in notification.php.