Last active
          September 10, 2021 08:51 
        
      - 
      
 - 
        
Save rafiahmedd/11087c38c49d8a20dedb781fba6dc9ee to your computer and use it in GitHub Desktop.  
Revisions
- 
        
rafiahmedd revised this gist
Sep 10, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php add_filter('fluentform_filter_email_attachments', function($emailAttachments, $notification,$form, $submittedData){ $target_form_id = 38;  - 
        
rafiahmedd created this gist
Sep 10, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ add_filter('fluentform_filter_email_attachments', function($emailAttachments, $notification,$form, $submittedData){ $target_form_id = 38; if($form->id != $target_form_id){ return; } $url = "https://www.australianshiatsucollege.com.au/documents/Prospectus.pdf"; $tmp = download_url($url); if (is_wp_error($tmp)) { return 'Error while downloading'; } $post_id = 0; // set 0 for no parent post id or simple attachment otherwise pass post id for include in post $desc = "Your Pdf"; $file_array = array(); // Set variables for storage // fix file filename for query strings preg_match('/[^?]+.(jpg|jpe|jpeg|gif|png|pdf)/i', $url, $matches); $file_array['name'] = basename($matches[0]); $file_array['tmp_name'] = $tmp; // If error storing temporarily, unlink if (is_wp_error($tmp)) { @unlink($file_array['tmp_name']); $file_array['tmp_name'] = ''; } // do the validation and storage stuff $id = media_handle_sideload($file_array, $post_id, $desc); // If error storing permanently, unlink if (is_wp_error($id)) { @unlink($file_array['tmp_name']); return $id; } $src = wp_get_attachment_url($id); $emailAttachments[] = get_attached_file($id); return $emailAttachments; }, 10, 4);