提交后,我的联系表将重定向到URL,后跟一个陌生的代码,例如#wpcf7-f1258-o1。但是我用了on_sent_ok:“ my_redirect();”在其他标题上。
请帮助!
答案 0 :(得分:0)
on_sent_ok
方法已从联系表7中删除。
请参阅:https://contactform7.com/2017/06/07/on-sent-ok-is-deprecated/
尝试在联系表格所在的页面上使用钩子:
add_action('wp_head', 'cf7_redirect_script');
function cf7_redirect_script(){
if(is_page('page-slug') { ?> // slug of the page which your contact form is on (can also be an ID)
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
// put the desired redirect URL below
location = 'http://yourdomain.com/thank-you';
}, false );
</script>
<?php }
}