Skip to main content

How to Auto-Download a PDF After Contact Form 7 Submission and Redirect to Thank You Page

 Do you want to give your visitors a PDF file instantly after they submit your Contact Form 7 form? Maybe it’s a brochure, catalog, eBook, or price list.


In this guide, I’ll show you how to:

✅ Automatically download a PDF after form submission
✅ Redirect the user to a custom Thank You page
✅ Keep it simple with just a few lines of code


🛠 Step 1: Upload Your PDF

  1. Go to WordPress Dashboard → Media → Add New

  2. Upload your PDF file

  3. Copy the File URL (you’ll need this for the code)


🛠 Step 2: Create a Thank You Page

  1. Go to Pages → Add New

  2. Name it “Thank You” (or any title you want)

  3. Add your message (e.g., “Thanks for contacting us! Check your email for more details.”)

  4. Publish the page and copy its URL


🛠 Step 3: Add JavaScript Code

Now we’ll add a small script to trigger the PDF download and redirect.

<script> document.addEventListener('wpcf7mailsent', function(event) { // 1. PDF URL (replace with your file link) var pdfUrl = "https://yourdomain.com/wp-content/uploads/yourfile.pdf"; // Trigger PDF download var link = document.createElement('a'); link.href = pdfUrl; link.download = "yourfile.pdf"; document.body.appendChild(link); link.click(); document.body.removeChild(link); // 2. Redirect to Thank You page (replace with your page URL) setTimeout(function(){ window.location.href = "https://yourdomain.com/thank-you"; }, 1000); // 1 second delay so download starts }, false); </script>

📌 Replace:

  • https://yourdomain.com/wp-content/uploads/yourfile.pdf → with your actual PDF URL

  • https://yourdomain.com/thank-you → with your Thank You page URL


🛠 Step 4: Where to Add the Code

You can add the script in two ways:

  • Option 1 (Recommended): Use the Code Snippets plugin → Create a new snippet → Insert into Footer.

  • Option 2: Edit your theme’s footer.php → Paste code before </body>.


🎯 Final Result

Now when a visitor submits your Contact Form 7 form:

  1. The PDF will automatically download

  2. The user will be redirected to your Thank You page

This is a great way to deliver lead magnets, brochures, or eBooks instantly and also track conversions on your Thank You page.


✅ Bonus Tip: Apply to Specific Form Only

If you have multiple forms and want this feature on just one form, you can target it by Form ID. Example:

if (event.detail.contactFormId == "1234") { // run download + redirect only for form ID 1234 }

👉 To find your form ID: Go to Contact → Contact Forms in WordPress, and you’ll see the ID next to your form name.


🎉 Conclusion

With this method, you can easily make Contact Form 7 download a PDF instantly and send visitors to a Thank You page. It’s perfect for businesses that want to share catalogs, eBooks, or guides automatically after form submission.

Comments

Popular posts from this blog

Tutorial : How To Convert PDF To Google Sheets [Easy]

In Today Digital Age, Whether You're student, a professional, or a business owner, you'll often find yourself needing to convert data from one format to another. One Most Common challenge is Converting PDF files into Google Sheets. In This Article  We comprehensive guide on how to convert PDF to Google Sheets efficiently and effectively. let's explore the various methods for converting your PDF files into Google Sheets. Convert PDF To Google Sheets Method 1: Using Google Drive Upload your PDF: Sign in to your Google Drive account, click the "+ New" button, and choose "File upload." Select your PDF file. Right-click the PDF: Once uploaded, right-click on the PDF file, choose "Open with," and select "Google Sheets." Review and adjust: Google Sheets will attempt to convert your PDF into a spreadsheet. Review the results and make any necessary adjustments. Save your work: Finally, save your converted file by clicking "File" ...

Organic Farm : Free Divi landing page layout

Landing pages are some of the most crucial pages of any website. They provide the information your visitors need to make a quick decision about your business, and direct readers to your call to action. Organic Farm displays a CTA over a full-screen image in parallax that moves in the opposite direction on scroll. The next section displays blurbs with large icons to show services with butiful hover effect. The Next Two Column Some information with image with animation. this layout you can Also use as Full One page Website. Organic Farm layout is Complete Solution for Your Website Contact Us Section, Map Section, Footer, News Section, Testimonial Section, Number Counter Section, About Us Section and Header Section All.. Organic Farm  Downlaod 

How to Save Contact Form 7 Entries in Your WordPress Backend

Contact Form 7 is a fantastic, free plugin that makes it super easy to create and manage contact forms on your WordPress website. You can whip up simple or complex forms in minutes, making it a go-to solution for many website owners. However, one of the default behaviors of Contact Form 7 is that it primarily sends form submissions to your designated email address. While this is essential, what happens if an email gets lost in spam, or you simply want a centralized place to manage all your inquiries? That's where saving Contact Form 7 entries directly in your WordPress backend comes in handy! Having these submissions stored within your WordPress database ensures you never miss a potential lead or important message. So, how do you achieve this? Thankfully, there are excellent plugins that seamlessly integrate with Contact Form 7 to provide this functionality. Let's explore a couple of popular options: Option 1: The Simplicity of Flamingo Developed by the same team behind Contact...