Skip to content

Instantly share code, notes, and snippets.

@reachkamrul
Created July 6, 2020 10:57
Show Gist options
  • Save reachkamrul/5f348c812ab692b7f376c6e1f5eb5b21 to your computer and use it in GitHub Desktop.
Save reachkamrul/5f348c812ab692b7f376c6e1f5eb5b21 to your computer and use it in GitHub Desktop.
<?php
/*
* Add Attachment to the email notification dynamically.
* @param $attachments array - Array of the attachments.
* @param $notification array - Email Notification array
* @param $form object - The Form Object
* @param $data array - The input submission data
* @return array
*/
add_filter('fluentform_filter_email_attachments', function ($attachments, $notification, $form, $data) {
if ($form->id != 91) { // Add your form id here
return $attachments;
}
/*
* You can check if $form or $notification and based on that push your file.
*/
$pathToYourFile = WP_CONTENT_DIR.'YOURFILE_PATH/file.pdf'; // Add path to your file
$attachments[] = $pathToYourFile; //
return $attachments;
}, 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment