简体   繁体   English

一页上的Recaptcha联系表格7和Mailchimp表格WP

[英]Recaptcha Contact form 7 and Mailchimp form on one page WP

Hi I have 2 forms on one page. 嗨,我在一页上有2个表格。 Contact form 7 and a Mailchimp form 联系表格7和Mailchimp表格

Mailchimp form recaptcha does not work because I think it is appearing twice: Mailchimp表单Recaptcha不起作用,因为我认为它出现了两次:

Contact Form 7 联络表格7

<script type="text/javascript" async src="https://www.gstatic.com/recaptcha/api2/r20170213115309/recaptcha__en.js"></script>

Mailchimp form Mailchimp表格

<script type="text/javascript" async src="https://www.gstatic.com/recaptcha/api2/r20170213115309/recaptcha__en.js"></script>

Errors in console: 控制台错误:

Uncaught Error: ReCAPTCHA placeholder element must be empty

On pages without contact form 7 the Mailchimp recaptcha works fine. 在没有联系表7的页面上,Mailchimp重新设置效果很好。

Any ideas? 有任何想法吗? do I have to deregister the contact form 7 script in functions file? 我必须在功能文件中注销联系表格7脚本吗? Or can I do with jquery? 或者我可以用jQuery吗?

您可以尝试使用Contact Form 7 MailChimp扩展https://uk.wordpress.org/plugins/contact-form-7-mailchimp-extension/

I managed a hack workaround. 我管理了一个黑客解决方法。

By loading recaptcha on all pages except the contact form page so contact form 7 and mailchimp share same script and not load twice. 通过在除联系表单页面之外的所有页面上加载Recaptcha,因此联系表单7和mailchimp共享相同的脚本,并且不会加载两次。 I added this to the head.php in WP 我将此添加到WP中的head.php

if( !is_page( array( 'contact-australia',))){ ?>
    <script src="https://www.google.com/recaptcha/api.js" async ></script>
<?php } ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM