bookmark_bordergform_notification_validation

Description

The gform_notification_validation filter can be used to validate custom notification settings added using the gform_notification_ui_settings and gform_pre_notification_save filters and override the default validation result.

Usage

The following would apply to all forms.

add_filter( 'gform_notification_validation', '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_notification_validation_FORMID)

add_filter( 'gform_notification_validation_5', 'your_function_name', 10, 3 );

Parameters

  • $is_valid boolean

    The result of the default notification validation which checks if the emails for the to, bcc, and replyTo settings are valid.

  • $notification array

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

  • $form

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

Examples

1. Require a setting

This example shows how the new setting added by the gform_notification_ui_settings and gform_pre_notification_save filters can be required.

add_filter( 'gform_notification_validation', 'notification_validation', 10, 3 );
function notification_validation( $is_valid, $notification, $form ) {

    if ( rgempty( 'my_custom_setting', $notification ) ) {
        $is_valid = false;
        GFCommon::add_error_message( esc_html( 'Please enter a value for the My Custom Label setting.' ) );
    }

    return $is_valid;
}

Since

This filter was added in Gravity Forms 1.9.16.

Source Code

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