Using Gravity Forms ‘gform_notification_disable_from_warning’ PHP filter

The gform_notification_disable_from_warning filter allows you to disable the “From Email” warning message in Gravity Forms notifications.

Usage

To disable the warning message, simply add the following code:

add_filter('gform_notification_disable_from_warning', '__return_true');

Parameters

  • $disable_from_warning (bool): Determines if the “From Email” warning should be disabled.

More information

See Gravity Forms Docs: gform_notification_disable_from_warning

This filter was introduced in Gravity Forms v2.4.13 and is located in notifications.php.

Examples

Disable the warning message for all notifications

This code snippet disables the “From Email” warning message for all form notifications.

add_filter('gform_notification_disable_from_warning', '__return_true');

Disable the warning message for a specific form

Disable the “From Email” warning message for a specific form by checking the form ID.

function disable_warning_for_specific_form($disable_warning, $form_id, $notification_id) {
    if ($form_id == 5) { // Replace 5 with your form ID
        return true;
    }
    return $disable_warning;
}
add_filter('gform_notification_disable_from_warning', 'disable_warning_for_specific_form', 10, 3);

Disable the warning message for a specific notification

Disable the “From Email” warning message for a specific notification by checking the notification ID.

function disable_warning_for_specific_notification($disable_warning, $form_id, $notification_id) {
    if ($notification_id == 'abcd1234') { // Replace 'abcd1234' with your notification ID
        return true;
    }
    return $disable_warning;
}
add_filter('gform_notification_disable_from_warning', 'disable_warning_for_specific_notification', 10, 3);

Disable the warning message based on the user role

Disable the “From Email” warning message for users with a specific role, such as “editor”.

function disable_warning_for_user_role($disable_warning, $form_id, $notification_id) {
    $current_user = wp_get_current_user();
    if (in_array('editor', $current_user->roles)) {
        return true;
    }
    return $disable_warning;
}
add_filter('gform_notification_disable_from_warning', 'disable_warning_for_user_role', 10, 3);

Disable the warning message for all forms except one

Disable the “From Email” warning message for all forms, except for a specific form.

function disable_warning_for_all_except_one($disable_warning, $form_id, $notification_id) {
    if ($form_id != 7) { // Replace 7 with the form ID you want to exclude
        return true;
    }
    return $disable_warning;
}
add_filter('gform_notification_disable_from_warning', 'disable_warning_for_all_except_one', 10, 3);