Created
October 3, 2014 18:26
-
-
Save irkanu/9360e05790bd2cd7d396 to your computer and use it in GitHub Desktop.
Gravity Form upload as attachment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gform_notification_FORMID, custom_function | |
add_filter('gform_notification_1', 'gfuaa_upload_attachment', 10, 3); | |
// http://gravityformspdfextended.com/topic/file-upload-as-attachments/ | |
function gfuaa_upload_attachment( $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["name"] == "Admin Notification"){ | |
$fileupload_fields = GFCommon::get_fields_by_type($form, array("fileupload")); | |
if(!is_array($fileupload_fields)) | |
return $notification; | |
$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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment