• Resolved Sapsford11

    (@sapsford11)


    I want the user to be able to download a PDF file after registering on the site with a simple ‘Name’ and ‘Email’ form.

    Is this possible with Contact Form 7? I have tried to combine with other plugins to achieve this but not been successful. I have also tried with the following code but no had any luck:

    .htaccess file:

    <FilesMatch "\.(?i:pdf)$">
       ForceType application/octet-stream
       Header set Content-Disposition attachment
    </FilesMatch>

    functions.php:

    function mycustom_wp_footer() {
    ?>
    <script type="text/javascript">
    document.addEventListener( 'wpcf7mailsent', function( event ) {
       if ( '1497' == event.detail.contactFormId ) {
          window.open( 'https://stagingarea2.craigsapsford.com/wpcontent/uploads/dlm_uploads/2017/11/Test-Document.pdf' );
       }
    }, false );
    </script>
    <?php
    }

    Can anyone assist me with this?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Why don’t you just put the file URL into the mail content?

    Thread Starter Sapsford11

    (@sapsford11)

    Hi,

    I’m not sure what you mean? When the form is completed, the users name and email is sent to the admin. Notifying her that someone has registered for the free download.

    How can I get a mail out to the user?

    Regards

    Craig

    Thread Starter Sapsford11

    (@sapsford11)

    Hi again,

    Ok i think i have a work around. If i use Mail (2) this email is sent to the user who fills in the form. I have inserted the file URL in this email so the user can have access to the PDF.

    Is this what you were referring to?

    Regards

    Craig

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Right.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Download PDF on form submission’ is closed to new replies.