【问题标题】:Contact form 7 send data and redirect to other domain page in wordpress联系表格 7 发送数据并重定向到 wordpress 中的其他域页面
【发布时间】:2022-02-25 01:36:56
【问题描述】:

我在 wordpress 上有多个联系表格 7,我希望一个表格重定向并发送帖子数据到其他域页面。 我在functions.php中添加了以下代码以重定向我的特定联系表单,数据已成功发送,但页面未重定向。

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;
}

【问题讨论】:

    标签: wordpress url-redirection contact-form-7


    【解决方案1】:

    以下是在 wpcf7mailsent 事件发生时将您重定向到另一个 URL 的脚本示例。

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

    【讨论】:

    • 您可以将其添加到页脚文件中
    • 如果我在页脚中添加它,那么它将重定向所有联系表单,但我只需要针对特定​​的联系表单,表单 ID 为 5240。
    猜你喜欢
    • 2014-10-08
    • 2023-03-22
    • 2018-04-16
    • 2021-08-19
    • 1970-01-01
    • 2010-12-21
    • 2018-07-10
    • 1970-01-01
    • 2014-08-27
    相关资源
    最近更新 更多