I'm trying to add images uploaded to a form as attachments to the notification email. I tried using the code on the Gform_Notification documentation page and I tried the code below from when 1.7 was in beta. Any help would be appreciated. The form is on this page:
http://www.scannellproductions.com/employee-tools/promo-sheet/
add_filter('gform_notification', 'change_admin_notification_attachments', 10, 3);
function change_admin_notification_attachments( $notification, $form, $entry ) {
if($notification["name"] == "Admin Notification"){
$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;
}
}
$notification["attachments"] = $attachments;
}
return $notification;
}
Posted 11 years ago on Monday July 1, 2013 |
Permalink