Hello Everybody !
I’ve been struggeling for a while with a form and need your help !
I try to add attachments in function.php.
Here is my code :
add_filter( 'gform_notification_5', 'rw_notification_attachments', 10, 3 );
function rw_notification_attachments( $notification, $form, $entry ) {
$log = 'rw_notification_attachments() - ';
if ( $notification['name'] == 'AKN' ) {
$url = rgar( $entry, '7' );
$uploaded_files = json_decode( stripslashes( $url ), true );
$attachment = array();
foreach ( $uploaded_files as $uploaded_file ) {
$attachment[] = $uploaded_file ;
$notification['message'] .= $uploaded_file;
$notification['message'] .= '<br>';
}
$notification['attachments'] = $attachment;
$notification['enableAttachments'] = 1;
}
return $notification;}
As you can see, I’ve also added the files links into the message. They are correctly displayed in the email recieved.
The filed 7 value is json :
[“https://www.serpinet-conseil.com/wp-content/uploads/gravity_forms/Plan_Paris_Mutiburo_Tour_Horloge.pdf",“https://www.serpinet-conseil.com/wp-content/uploads/gravity_forms/BDA.zip”,"https://www.serpinet-conseil.com/wp-content/uploads/gravity_forms/CD.zip”]
Thanks !