bookmark_bordergform_admin_notification_attachments

Description

This filter can be used to add attachments to the admin notification email.

This hook has been deprecated in v. 1.7. Please use gform_notification instead.

Usage

add_filter( 'gform_admin_notification_attachments', 'add_attachment', 10, 3 );

You can also target a specific form by adding the form id after the hook name.

//This filter declaration targets a form whose id is 6
add_filter( 'gform_admin_notification_attachments_6', 'add_attachment', 10, 3 );

Parameters

  • $attachments string, array

    The attachments to be filtered. It can be a simple strings containing for file path for one attachments or an array of strings for multiple attachments.

  • $entry Entry Object

    Current entry object.

  • $form

    Current form object.

Examples

This example attaches all file upload fields in the form to the admin notification email.

add_filter( 'gform_admin_notification_attachments_4', 'add_attachment', 10, 3 );
function add_attachment( $attachments, $lead, $form ) {
	$fileupload_fields = GFCommon::get_fields_by_type( $form, array( 'fileupload' ) );
	if ( ! is_array( $fileupload_fields ) ) {
		return $attachments;
	}
	$attachments = array();
	$upload_root = RGFormsModel::get_upload_root();
	foreach ( $fileupload_fields as $field ) {
		$url = $lead[ $field['id'] ];
		$attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $url );
		if ( $attachment ) {
			$attachments[] = $attachment;
		}
	}
	return $attachments;
}

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

This filter is located in common.php