gform_email_fields_notification_admin

Description

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

Usage

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

ParameterTypeDescription
$field_listarrayAn array of Field Objects to be displayed in the drop down.
$formForm ObjectThe current form.

Examples

Add a field to the email fields list.

The following 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;
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

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