• akira9000

    (@akira9000)


    Hi,

    I have a pretty simple form containing a dropdown of 3 options. A,B,C. Each option refers to a different PDF file. Lets say test1.pdf, test2.pdf and test3.pdf for arguments sake.

    The form uses Mail(2) as an autoresponder back to the person filling the form in. How can I make it so that choosing dropdown A attaches test1.pdf to the email, choosing B attaches test2.pdf and so on.

    I have tried adding the dropdown reference in the attachments field instead of the relative file URL but then nothing attaches to the email. I have also tried coding the dropdown choices with name, then pipe, then file url but does not seem to push through to the final email.

    Is this even possible?

    Cheers guys

Viewing 5 replies - 1 through 5 (of 5 total)
  • konsument

    (@konsument)

    1 min google ??

    • This reply was modified 7 years ago by konsument.
    Thread Starter akira9000

    (@akira9000)

    I did see that konsument but when I changed the details the form no longer sends. I added this to my functions file:

    add_action( 'wpcf7_before_send_mail', 'my_dynamic_attachments' );
    function my_dynamic_attachments($cf7)
    {
         //check if it is the registration form
         if ($cf7->id==630)
         {
          // get the dropdown menu value and the corresponding file
          $filename = uploads/2017/11/test1.pdf($cf7->form['checkbox-233']);
    
          $cf7->uploaded_files = array('test1'=>$filename);
         }
    }
    

    Can you advise where I went wrong?

    My form ID is 630, my field ID is checkbox-233 and finally my checkbox ID is test1.
    My initial post said a dropdown but it’s actually a set of 3 tickboxes I’m using. My mistake.

    Thanks for your advise.

    konsument

    (@konsument)

    Thread Starter akira9000

    (@akira9000)

    Seen this also. As you can probably tell, my PHP is not great. This bit of code only targets a specific form – ID741

    add_action('wpcf7_before_send_mail','send_pdf');
    
    function send_pdf( $cf7 ) {
        $id = $cf7->id();
        if ($id==741){
            $submission = WPCF7_Submission::get_instance();
            $submission->add_uploaded_file('pdf', get_template_directory().'/test.pdf');
        }
    }
    

    What can I add to target not just a specific form, but the checkbox items within that form?

    konsument

    (@konsument)

    since I’m not a specialist either, you might get replies from others if you post a link to your form

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘attach files dynamically to Mail(2) possible?’ is closed to new replies.