Using Gravity Forms ‘gform_email_fields_notification_admin’ PHP filter

The gform_email_fields_notification_admin filter is used to add or remove fields from the list of email fields displayed on the Notification edit page when configuring the “Send To Field”.

Table of contents

Usage

A generic example of how to use the filter:

add_filter('gform_email_fields_notification_admin', 'add_field_to_email_list', 10, 2);

Applies to a specific form. In this case, form id 5:

add_filter('gform_email_fields_notification_admin_5', 'add_field_to_email_list', 10, 2);

Parameters

  • $field_list (array): An array of Field Objects to be displayed in the drop-down.
  • $form (Form Object): The current form.

More information

See Gravity Forms Docs: gform_email_fields_notification_admin

Examples

Add a field to the list of email fields

This example adds a field (field with ID=1) to the list of email fields displayed in the drop-down.

add_filter('gform_email_fields_notification_admin', 'add_field_to_email_list', 10, 2);

function add_field_to_email_list($field_list, $form) {
    // Adds field with ID=1 to the list of email fields
    foreach ($form['fields'] as $field) {
        if ($field->id == '1') {
            $field_list[] = $field;
            break;
        }
    }
    return $field_list;
}

Place this code in the functions.php file of your active theme.

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

Leave a Comment

Your email address will not be published. Required fields are marked *