Using Gravity Forms ‘gform_default_notification’ PHP action

The gform_default_notification filter in Gravity Forms PHP allows you to disable or enable the default admin notification that is automatically generated for new forms.

Usage

add_filter('gform_default_notification', 'your_custom_function');
function your_custom_function($is_enabled) {
    // your custom code here
    return $is_enabled;
}

Parameters

  • $is_enabled (bool) – Passes true by default, return false to disable the default admin notification.

More information

See Gravity Forms Docs: gform_default_notification

Examples

Disable Default Admin Notification

Disable the default admin notification for all new forms.

add_filter('gform_default_notification', '__return_false');

Disable Default Admin Notification for a Specific Form

Disable the default admin notification only for form with ID 5.

add_filter('gform_default_notification', 'disable_notification_for_form_5', 10, 2);
function disable_notification_for_form_5($is_enabled, $form) {
    if ($form['id'] == 5) {
        return false;
    }
    return $is_enabled;
}

Enable Default Admin Notification for a Specific Form

Enable the default admin notification only for form with ID 3 and disable for all others.

add_filter('gform_default_notification', 'enable_notification_for_form_3', 10, 2);
function enable_notification_for_form_3($is_enabled, $form) {
    if ($form['id'] == 3) {
        return true;
    }
    return false;
}

Disable Default Admin Notification Based on User Role

Disable the default admin notification for users with the ‘editor’ role.

add_filter('gform_default_notification', 'disable_notification_for_editors', 10, 2);
function disable_notification_for_editors($is_enabled, $form) {
    if (current_user_can('editor')) {
        return false;
    }
    return $is_enabled;
}

Disable Default Admin Notification on Weekends

Disable the default admin notification for new forms submitted on weekends.

add_filter('gform_default_notification', 'disable_notification_on_weekends', 10, 2);
function disable_notification_on_weekends($is_enabled, $form) {
    $day_of_week = date('w');
    if ($day_of_week == 0 || $day_of_week == 6) { // 0 is Sunday, 6 is Saturday
        return false;
    }
    return $is_enabled;
}