gform_pre_notification_save

Description

Modify the notification object before it is saved to the database. This is particularly useful when saving custom notification settings to the notification object.

Usage

The following would apply to all forms.

add_filter( 'gform_pre_notification_save', 'your_function_name', 10, 2 );

To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_pre_notification_save_FORMID)

add_filter( 'gform_pre_notification_save_5', 'your_function_name', 10, 2 );

Parameters

  • $notification array

    An array of properties which make up the notification object to be saved. See Notifications Object for default properties.

  • $form Form Object

    The current form object to which the notification being saved belongs.

Examples

This example demonstrates how you can add the value entered via our gform_notification_ui_settings to the notification object before it is saved to the database. Use with the gform_notification_ui_settings hook to display your custom settings UI.

If your UI settings have a “name” attribute, they will be submitted along with the rest of the default notification settings. We can then retrieve our custom value from the $_POST using the Gravity Forms helper function rgpost().

add_filter( 'gform_pre_notification_save', 'my_custom_notification_save', 10, 2 );
function my_custom_notification_save( $notification, $form ) {
    $notification['my_custom_setting'] = rgpost( 'my_custom_setting' );
    return $notification;
}

Source Code

This filter is located in GFNotification::notification_edit_page() in notification.php