The gform_disable_notification Gravity Forms PHP filter allows you to disable admin and user notification emails.
Usage
add_filter( 'gform_disable_notification', 'your_function_name', 10, 4 );
Parameters
- $is_disabled (bool): Variable to be filtered. Set it to true to disable notifications.
- $notification (array): Current Notification array.
- $form (Form Object): Current form.
- $entry (Entry Object): Current Entry array.
More information
See Gravity Forms Docs: gform_disable_notification
Examples
Disable ALL Notifications
This example disables admin and user notifications for all forms.
add_filter( 'gform_disable_notification', 'disable_notification', 10, 4 ); function disable_notification( $is_disabled, $notification, $form, $entry ) { return true; }
Disable a notification based on a field
This example shows you how to disable a notification conditionally based on a field of the entry. This can help you in situations where conditional logic can’t be used (e.g. To send a notification only if an upload field was not used).
add_filter( 'gform_disable_notification', 'disable_notification_by_field', 10, 4 ); function disable_notification_by_field( $is_disabled, $notification, $form, $entry ) { $field_to_check = rgar( $entry, '1' ); // Replace 1 by your field id number // Replace User Notification by your notification name. if ( $notification['name'] == 'User Notification' && !empty( $field_to_check ) ) { // Disable notification only if $field_to_check is not empty. return true; } return $is_disabled; }
Update from gform_disable_user_notification
This example shows you how to update your code from the deprecated gform_disable_user_notification hook.
add_filter( 'gform_disable_notification', 'disable_notification', 10, 4 ); function disable_notification( $is_disabled, $notification, $form, $entry ) { //There is no concept of user notifications anymore, so we will need to disable notifications based on other criteria such as name if ( $notification['name'] == 'User Notification' ) { return true; } return $is_disabled; }
Update from gform_disable_admin_notification
This example shows you how to update your code from the deprecated gform_disable_admin_notification hook.
add_filter( 'gform_disable_notification', 'disable_notification', 10, 4 ); function disable_notification( $is_disabled, $notification, $form, $entry ) { //There is no concept of admin notifications anymore, so we will need to disable notifications based on other criteria such as name if ( $notification['name'] == 'Admin Notification' ) { return true; } return $is_disabled; }
Disable notifications for a specific form
This example shows how to disable notifications for a specific form by adding the form id after the hook name.
add_filter( 'gform_disable_notification_6', 'disable_notification_for_form', 10, 4 ); function disable_notification_for_form( $is_disabled, $notification, $form, $entry ) { return true; }