2017-08-08 94 views
0

我在wordpress上有多個聯繫表單7,我希望一個表單可以將發送數據發送到其他域頁面。 我在functions.php中添加了以下代碼,用於重定向我的特定聯繫表單,數據已成功發送但頁面未重定向。聯繫表格7發送數據並重定向到wordpress中的其他域頁面

add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url'); 
function wpcf7_custom_form_action_url($url) 
{ 
global $post; 
$id_to_change = 5240; 
if($wpcf7_contact_form->ID === $id_to_change) 
    return 'http://34.209.247.91:8069/page/register'; 
else 
    return $url; 
} 

回答

0

以下是當wpcf7mailsent事件發生時,您重定向到另一個URL腳本示例。

<script> 
document.addEventListener('wpcf7mailsent', function(event) { 
location = 'http://example.com/'; 
}, false); 
</script> 
+0

我在哪裏需要添加此代碼? – Sanj

+0

你可以將其添加到頁腳文件 – Chinou

+0

如果我在頁腳中添加它,那麼它將重定向所有聯繫人窗體,但我只需要一個特定的聯繫人窗體,窗體ID是5240。 – Sanj

相關問題