PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Attach csv file to email in certain forms

  1. HI

    I have the following code to attach documents in my functions.php file, if I wanted to add a file ID with the csv attached how would I amend the code so that it still sends these files and the csv to another form, for example form 1?
    CODE in functions.php:

    <?php
    add_filter("gform_user_notification_attachments", "add_attachment", 10, 3);
    function add_attachment($attachments, $lead, $form) {
    
        if ( $form[ 'id' ] == 17 )  {
            $doc = '/The-Membership-Rules.pdf';
        } elseif( $form[ 'id' ] == 22 ) {
            $doc = '/The-Membership-Rules.pdf';
        } else {
          $doc = '';
        }
    
        $upload = wp_upload_dir();
        $upload_path = $upload["basedir"];
    
        $attachments = array();
        $attachments[] = $upload_path . $doc;
    
        return $attachments;
    
    }
    ?>

    Thanks
    Nic

    Posted 12 years ago on Monday October 29, 2012 | Permalink
  2. Thank you for starting a new topic. What is "a file ID with the csv attached"? It sounds like you're trying to attach different files when different forms are submitted, or multiple files to some form submissions? Can you give a scenario where this is in use? Thank you.

    Posted 12 years ago on Wednesday October 31, 2012 | Permalink
  3. HI

    This part works fine and when a person fills in one of the above forms they receive the pdf, however I would like to be able to add so that if someone fills in form ID 20 for example that it sends them the csv file for that form and sends it as an attachment in the same email.
    Is this possible?

    Thank you
    Nic

    Posted 12 years ago on Wednesday October 31, 2012 | Permalink
  4. What is "the CSV for that form"? How is the CSV created and what does it contain? It does not sound like it's related at all to your PDF attachments, but you just want to be able to use the same gform_user_notification_attachments hook and send another file when the submission is from another form.

    Posted 12 years ago on Wednesday October 31, 2012 | Permalink