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 

Optimizing Your E-commerce Site: How to Modify Category Order in WordPress and WooCommerce

Have you ever tried to change the default order of the category in your WordPress and WooCommerce site? If the answer is yes, then you’ll be surprised to know how easily you can change category orders using our effective ways. The arrangement of categories plays a pivotal role in shaping how your audience interacts with your content. However, WordPress, in its default configuration, arranges categories alphabetically, resulting in a rigid and sometimes confusing category list. This situation highlights the importance of customizing category orders in WordPress to create a more engaging and meaningful user experience. WooCommerce site owners face a similar challenge when it comes to product categories, prompting them to seek ways to tailor the order. In this article, we will provide you with step-by-step instructions on how to modify category and taxonomy term orders in WordPress, and how to rearrange product categories in WooCommerce.  Changing the category order in WordPress and W...