Attach select file uploads to notification but not all

In our business we need to appoint our new hires with our partner companies. That usually means sending separate emails to 30+ companies with separate attachments (company specific forms) and other common information. I’m trying to build a form that allows me to enter info like name, DOB, email, etc plus 30+ separate upload fields where I can upload the company-specific forms for company A, company B, company C, etc. I then want notifications to go out to each of those 30+ companies with the common information but just their company-specific form attached to their notification. The attachment can’t be hyperlinked in the body of the email. Most of these companies have IT security rules that prevent them from accessing the hyperlinked files.

I can’t find a way to do this. Does anyone know if this can be done?

It can be done. It would require some customization using the gform_notification filter to actually conditionally attach the correct upload to the proper notification.

Thanks, I’ll take a look at that.

I found the code you are referencing, but I can’t figure out the variables that I need to use. I have this code pasted into my functions.php file of my child theme.

add_filter( 'gform_notification_32' , 'change_user_notification_attachments' , 10, 3 );

function change_user_notification_attachments( $notification , $form , $entry ) {

//There is no concept of user notifications anymore, so we will need to target notifications based on other criteria, such as name

if ( $notification [ 'test notification' ] == 'User Notification' ) {

$fileupload_fields = GFCommon::get_fields_by_type( $form , array ( 'fileupload' ) );

if ( ! is_array ( $fileupload_fields ) )

return $notification ;

$notification [ 'attachments' ] = ( is_array ( rgget( 'attachments' , $notification ) ) ) ? rgget( 'attachments' , $notification ) : array ();

$upload_root = RGFormsModel::get_upload_root();

foreach ( $fileupload_fields as $field ) {

$url = $entry [ $field ->id ];

$attachment = preg_replace( '|^(.*?)/gravity_forms/|' , $upload_root , $url );

if ( $attachment ) {

$notification [ 'attachments' ][] = $attachment ;




return $notification ;


I’m working with a test form (form ID=32) and have a single notification called “test notification” and I have two file upload fields, {File:1} and {File:2}. How would I change to above code to only attach {File:1}?


I’d really appreciate help with this. It’s the last piece I need to figure out on a large scale form I’m building.