防止在wordpress出现错误时将cf7重定向到thankyou
我有一个cf7,有3个字段:姓名、电子邮件和选择框,在下拉列表中,根据选择表单重定向到不同的感谢页面。问题是,如果表单显示一些错误消息,如发送消息时出错、输入无效等。表单不应重定向到感谢页面 我尝试了联系表单7自定义DOM事件,如wpcf7mailfailed、wpcf7invalid防止在wordpress出现错误时将cf7重定向到thankyou,wordpress,Wordpress,我有一个cf7,有3个字段:姓名、电子邮件和选择框,在下拉列表中,根据选择表单重定向到不同的感谢页面。问题是,如果表单显示一些错误消息,如发送消息时出错、输入无效等。表单不应重定向到感谢页面 我尝试了联系表单7自定义DOM事件,如wpcf7mailfailed、wpcf7invalid function cf7_footer_script(){ ?> <script> document.addEventListener( 'wpcf7submit', function( ev
function cf7_footer_script(){ ?>
<script>
document.addEventListener( 'wpcf7submit', function( event ) {
if ( '7084' == event.detail.contactFormId ) {
var lpLocation = document.getElementById("careers").value;
if (lpLocation == "Hire better employees") {
location = 'url1';
} else if (lpLocation == "I want to match people to the best careers") {
location = 'url2';
}
else if(lpLocation=="I want to learn more about both"){
location = 'url3';
}
}
}, false );
</script>
<?php }
add_action('wp_footer', 'cf7_footer_script');
函数cf7\u footer\u script(){?>
document.addEventListener('wpcf7submit',函数(事件){
如果('7084'==event.detail.contactFormId){
var lpLocation=document.getElementById(“职业”).value;
如果(lpLocation==“雇用更好的员工”){
位置='url1';
}else if(lpLocation==“我想让人们找到最好的职业”){
位置='url2';
}
else if(lpLocation==“我想了解这两个方面的更多信息”){
位置='url3';
}
}
},假);
您可以尝试使用此“document.addEventListener”('wpcf7mailssent',函数(事件)”
函数cf7\u footer\u script(){?>
document.addEventListener('wpcf7mailsent',函数(事件){
如果('7084'==event.detail.contactFormId){
var lpLocation=document.getElementById(“职业”).value;
如果(lpLocation==“雇用更好的员工”){
位置='url1';
}else if(lpLocation==“我想让人们找到最好的职业”){
位置='url2';
}
else if(lpLocation==“我想了解这两个方面的更多信息”){
位置='url3';
}
}
},假);
使用wpcf7mailssent而不是wpcf7submit事件。您只需更改联系人表单7自定义DOM事件,使用wpcf7mailssent而不是wpcf7submit
wpcf7mailsent-当Ajax表单提交成功完成且邮件已发送时激发。
函数cf7\u footer\u script(){?>
document.addEventListener('wpcf7mailsent',函数(事件){
如果('7084'==event.detail.contactFormId){
var lpLocation=document.getElementById(“职业”).value;
如果(lpLocation==“雇用更好的员工”){
位置='url1';
}else if(lpLocation==“我想让人们找到最好的职业”){
位置='url2';
}else if(lpLocation==“我想了解这两个方面的更多信息”){
位置='url3';
}
}
},假);
You can try with this "document.addEventListener( 'wpcf7mailsent', function( event ) "
function cf7_footer_script(){ ?>
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '7084' == event.detail.contactFormId ) {
var lpLocation = document.getElementById("careers").value;
if (lpLocation == "Hire better employees") {
location = 'url1';
} else if (lpLocation == "I want to match people to the best careers") {
location = 'url2';
}
else if(lpLocation=="I want to learn more about both"){
location = 'url3';
}
}
}, false );
</script>
<?php }
add_action('wp_footer', 'cf7_footer_script');
function cf7_footer_script() { ?>
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '7084' == event.detail.contactFormId ) {
var lpLocation = document.getElementById( "careers" ).value;
if ( lpLocation == "Hire better employees" ) {
location = 'url1';
} else if ( lpLocation == "I want to match people to the best careers" ) {
location = 'url2';
} else if( lpLocation == "I want to learn more about both" ) {
location = 'url3';
}
}
}, false );
</script>
<?php }
add_action( 'wp_footer', 'cf7_footer_script' );