-1

I want contact form 7 to redirect to a specific page when on_sent_ok is successful.

Unfortunately, the domain of the page to which I want to redirect is not fixed, it changes time to time. But, the rest part of the url remains same.

I have many contact forms. So, if the domain changes, I have to manually change the value of url in all the contact forms. Which is very painful.

So, what I want to do is simple:

  1. I want to create a variable containing the domain name (say, $redirect_domain_name) and store it inside some php file of the plugin.

  2. Then I want to use the variable in the additional settings of Contact From 7 to redirect my users to the correct url.

This way, I don’t have to edit additional settings of all the contact forms manually when the domain changes. I can just change the value of that($redirect_domain_name) variable and all the URLs will automatically be updated.

Can anybody tell me how can I do this?

Thanks in advance :)

  • If you have a question about the inner workings of a third party plugin/theme, you have a better chance of getting an answer at its author's forum – cjbj Jan 5 '17 at 9:56
0

if only the domain changes, you could try using relative urls:

document.location="/thank-you";

But if the domain you're redirecting to is different than the page you're on, a simple way to fix this problem would be to add a customizer value redirect_domain, and then make it a global variable in footer.php

<script>var RedirectUrl=<?php echo get_theme_mod(redirect_domain);?></script>

then in your on_sent_ok you should be able to use the RedirectUrl variable

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.