提交后联系表格7重定向 [英] Contact Form 7 redirect after submission

查看:86
本文介绍了提交后联系表格7重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用联系表单7,并且在成功提交联系表单后尝试重定向到另一个页面。



我已经尝试使用联系表单7 –成功页面重定向( https:// nl- be.wordpress.org/plugins/contact-form-7-success-page-redirects/ ),但该插件与主题不兼容,并且会出现一些错误。



是否有另一种不使用该插件进行重定向的方法?
我已经找到了 https://contactform7.com/也可以重定向到另一个URL-submissions / ,但是我无法实现它。重定向也仅对于网站上的一种联系方式是必需的,而不是全部。



谢谢!


解决方案

我看到了很多答案相同的答案。当您有10个表格和10个不同的感谢页面时,主要的问题来了,而该解决方案将无法使用。



我对此有一种解决方法。



第1步:在表单中创建一个隐藏字段,并在其中添加谢谢页面URL。

  [隐藏的thankyouURL id:thankyouURL默认值:http://example.com/thank-you/ http:// example .com / thank-you /] 

步骤2:在DOM事件中,谢谢

 < script> 
document.addEventListener('wpcf7mailsent',function(event){
varthankyouURL = document.getElementById( thankyouURL)。value;
location = thankyouURL;
},false );
< / script>

就是这样。


I'm using contact form 7 and I'm trying to redirect to another page after a successful contact form submission.

I've tried using Contact Form 7 – Success Page Redirects (https://nl-be.wordpress.org/plugins/contact-form-7-success-page-redirects/) but the plugin isn't compatible with the theme and gives some errors.

Is there another way to redirect without using that plugin? I've found this https://contactform7.com/redirecting-to-another-url-after-submissions/ too, but I'm not able to implement it. The redirection is also only necessary for one contact form on the site, not all of them.

Thank you!

J.

解决方案

I've seen quite a few answers with the same responses. The major question comes when you have 10 forms and 10 different thank you pages and this solution won't work.

I have a workaround for this.

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>

That's it.

这篇关于提交后联系表格7重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆