Contact Form 7 redirect after submission without a plugin, possible?

Disclosure: This post contains affiliate links. I may receive compensation when you click on links to products in this post. For an explanation of my Advertising Policy, visit this page. Thanks for reading!

How to use the Contact Form 7 redirect after a submission without a plugin. FAQs

If you insist on using a Contact 7 Forms redirect after submission but without a plugin, then you’re going to have to do some coding. 

Below I will give you various coding options that you can try to use a Contact 7 Forms redirect after submission, without a plugin. 

However, these aren’t for the weak of heart and you really need to know your PHP, Javascript and your website’s theme in order to implement it without crashing your site. 

I will also give you links to the sources of some of these code solutions so you can do further research on your own if necessary. 

However, my advice would be to simply use a WordPress plugin for Contact 7 Forms redirect after submissions, here, “Contact Form 7 Redirect & Thank You Page Pro

Anyway, here are the codes, use them at your discretion:

Contact Form 7 redirect after a submission without a plugin, Code Solution 1.

This first workaround is useful when you have something like 10 different forms and 10 different “Thank you” pages:

Step 1: Create a hidden field in your form and add the thank you page URL in that.

[hidden thankyouURL id:thankyouURL default:http://example.com/thank-you/ “http://example.com/thank-you/”]

Step 2: In the DOM event, get the thank you URL from the field and redirect the user.

<script>

document.addEventListener( ‘wpcf7mailsent’, function( event ) {

    var thankyouURL = document.getElementById(“thankyouURL”).value;

    location = thankyouURL;

}, false );

</script>

Contact Form 7 redirect after a submission without a plugin, Code Solution 2.

This next workaround you will need to go into your theme’s PHP files.

Add below code in functions.php (located in themes -> themeName Folder)

add_action( ‘wp_footer’, ‘mycustom_wp_footer’ );

function mycustom_wp_footer() {

?>

<script type=”text/javascript”>

document.addEventListener( ‘wpcf7mailsent’, function( e ) {

    var str = window.location.href;

    if( str.includes(“flp”) ){

        window.location.href = “http://www.YourWebsite.com/facebook-thank-you”;

    } else if( str.includes(“glp”) ){

        window.location.href = “http://www.YourWebsite.com/google-thank-you”;

    }

}, false );

</script>

<?php

}

Contact Form 7 redirect after a submission without a plugin, Code Solution 3.

If you have multiple forms on the same page (For example, IDs must be unique, or the redirect ID is on the page, but the user submits a different form).

The code below tries to fix these potential issues. This answer uses hidden form fields in CF7, but allows you to have a unique redirect URL for each form without having to edit your JS code every time you create a new form (just use a consistent name, such as “url_redirect” as shown in the code below):

Contact Form 7:

[hidden url_redirect “http://customurl.com?customvar=1“]

Javascript:

document.addEventListener( ‘wpcf7mailsent’, function( e ) {

    var url_redirect = ”;

    var inputs = e.detail.inputs;

    for ( var i = 0; i < inputs.length; i++ ) {

        if( ‘url_redirect’ == inputs[i].name ) {//used for misc forms

            url_redirect = inputs[i].value;//set the redirect value from current submitted form

        }

    }

    //Check for redirect 

    if( url_redirect ){

        location = url_redirect;

    }

The source for these codes comes from:Contact Form 7 redirect after submission” on Stackoverflow.com.

Remember to always make a backup of your WordPress site before attempting any changes in code or adding new code. 

At the very least you should make a copy of the PHP code in the area of your theme you intend working on before changing it.

Why you should use the Contact 7 Redirect WordPress Plugin.

Despite the possible coding solutions above, the best way to take care of any Contact 7 Form redirects after submission issues, is to simply download this plugin, “Contact Form 7 Redirect & Thank You Page Pro”. 

I know what you’re thinking, “Many plugins, unfortunately, are not updated on a regular basis and cause more problems than they solve.” 

However, this plugin, as of the writing of this post, was updated just 2 weeks ago. So the developers at Contact Form 7 seem to be on top of their excellent tool. So use it. That’s what plugins are for. 

Below, I will go through some additional troubleshooting tips that you might want to consider first before reaching out to Contact 7 Form’s support.

Contact Form 7 redirect after submit is not working. Troubleshooting tips.

Your Contact Form 7 after submit might not be working due to a few reasons. Many of the redirect after submission issues with Contact Form 7 can be resolved by trying these next simple steps.

Conflicting scripts.

Since Contact Form 7 uses JavaScript, it might not play nice with some of the other plugins you have in your WordPress dashboard. 

There are a few more things that you might also want to check to fix this issue. 

Check your settings.

The first would be to try changing the redirect method on the Contact Form 7 settings page.

Try the plugin, “Redirection for Contact Form 7”.

The second would be to try this plug-in, “Contact Form 7 Redirect & Thank You Page Pro” and see if it works. 

Check your theme.

You also might want to check with the theme you’re using. There have been some situations where Contact Form 7 doesn’t play nice with some Elegant Themes, in particular, the very popular Divi theme for example. 

So before troubleshooting on the Contact Form 7 plugin side of the issue, check with your theme’s author and their support section. Let them know what your issues are. Many times the redirect after submit issues are with the theme and not the plugin. 

Your theme’s support may have already had experience in dealing with Contact Form 7 redirect after submission issues and have a few solutions you can try. 

Contact Form 7 redirect after submission without a plugin, conclusions.

As you can see from above, you can try a few coding solutions to solve a Contact Form 7 redirect after submission without having to use a plug-in.

But unless you are an experienced developer who knows PHP and Javascript, then using a few troubleshooting tips along with the plugin, “Contact Form 7  Redirect & Thank You Page Pro”, should fix 95% of any Contact Form 7 redirect after submission issues.

However when you think about it, the codes that I have given you above are basically plugins. I mean they’re not plugins in the technical sense of the word. These aren’t listed on the WordPress plugin page where you can just download them onto your WordPress dashboard. 

But for all intents and purposes, that’s what plugins are. Pieces of code that are downloaded into your WordPress website and automatically placed into the correct PHP file that your WordPress website is run on after you activate them. 

So unless you are a coder, my advice would be just to simply use the plugin, ““Contact Form 7 Redirect & Thank You Page Pro” that’s available for Contact Form 7. The developers of Contact Form 7 seem to be quite on top of these issues as well as updates. 

In fact, why wouldn’t you use that Contact Form 7 Redirect & Thank You Page Pro after submission plugin, instead of fiddling around with PHP and JavaScript? 

Either way, that’s how you can fix redirect Contact Form 7 after submission issues, with or without a plug-in.

Web hosting in Iceland - OrangeWebsite.com