The gform_notification_validation filter is 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
To apply the filter 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 that 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.
More information
See Gravity Forms Docs: gform_notification_validation
Examples
Require a setting
This example demonstrates how to require a new setting added by the gform_notification_ui_settings
and gform_pre_notification_save
filters.
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; }
Note: This filter was removed in Gravity Forms v2.5 and is no longer supported. From Gravity Forms 2.5, notification settings and their validation callbacks are now defined via the gform_notification_settings_fields
filter.