Plugin Directory

Changeset 1589093


Ignore:
Timestamp:
02/04/2017 10:45:18 PM (9 years ago)
Author:
Jebble
Message:

Fix: When multiple upload fields are present, all files are now added as attachments correctly.

Location:
gf-uploads-as-attachments
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • gf-uploads-as-attachments/trunk/gforms-uploads-as-attachments.php

    r1381778 r1589093  
    44Plugin URI: https://github.com/Jebble/Gravity-Forms-Uploads-as-Attachments
    55Description: Adds an option to send files from the fileupload field(s) as attachment with notifications
    6 Version: 1.1.1
     6Version: 1.2.0
    77Author: Jebble
    88Author URI: http://jebble.nl/
     
    113113            foreach ( $fileuploadfields as $field ) {
    114114                $url = $entry[ $field['id'] ];
    115             }
    116115
    117             if ( ! empty( $url ) ) {
    118                 if ( $field['multipleFiles'] ) {
    119                     $uploaded_files = json_decode( stripslashes( $url ), true );
    120                     foreach ( $uploaded_files as $uploaded_file ) {
    121                         $attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $uploaded_file );
    122                         $attachments[] = $attachment;
    123                     }
    124                 } else {
    125                     $attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $url );
    126                     $attachments[] = $attachment;
    127                 }
     116                if ( ! empty( $url ) ) {
     117
     118                    if ( $field['multipleFiles'] ) {
     119                        $uploaded_files = json_decode( stripslashes( $url ), true );
     120                        foreach ( $uploaded_files as $uploaded_file ) {
     121                            $attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $uploaded_file );
     122                            $attachments[] = $attachment;
     123                        }
     124                    } else {
     125                        $attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $url );
     126                        $attachments[] = $attachment;
     127                    }
     128                }
     129
    128130            }
    129131
    130             $notification['attachments'] = $attachments;
     132            $notification['attachments'] = $attachments;
    131133        }
    132134
  • gf-uploads-as-attachments/trunk/readme.txt

    r1466183 r1589093  
    4040
    4141== Changelog ==
     42#####1.2.0
     43- Fixed multiple upload fields.
     44In certain cases only the file(s) from the last upload field in a form was added as an attachment. This problem is now solved.
     45
    4246#####1.1.0
    4347- Corrected preparation for i18n localization.
Note: See TracChangeset for help on using the changeset viewer.