【问题标题】:Change action in Contact Form 7更改联系表 7 中的操作
【发布时间】:2015-08-02 09:59:58
【问题描述】:

发送邮件后会修改 Contact Form 7 的操作。

我关注this post 并且炒得很好。但是我的 fom 处于 Bootstrap 模式中,我希望它们在提交时保持打开状态。

我的代码是。 在 PHP 函数中

add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url'); function wpcf7_custom_form_action_url() {  return 'http://saviacomunicacion.com.ar/test2014#sala-de-prensa'; }

在其他设置字段中

add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');

这会重定向 URL,但不会发送邮件。 我希望我可以发送邮件并保持模式打开以显示响应:您的邮件发送正确。

谢谢

【问题讨论】:

    标签: wordpress twitter-bootstrap contact-form-7


    【解决方案1】:

    根据doc,还有另一种方法可以完成重定向。只需将一些代码添加到插件仪表板即可。 或者你可以做自定义js函数

    在插件选项中

    on_sent_ok: "customFunction();"
    

    在代码中的某处

    <script>
        function customFunction() {
            // show your modal here
            $('#myModal').modal();
        }
    </script>
    

    【讨论】:

    • 不工作,页面仍在重新加载,我想发送邮件并保持模式显示,但不重新加载页面。我试过这个j(document).on('mailsent.wpcf7', function (event) { event.preventDefault(); j('#urlModal').modal(); }); 但没用
    【解决方案2】:

    我用这段代码找到了我的解决方案。提交表单时,模态框会在 1 秒后关闭。 我没有保持 Modal 打开,而是在关闭后等待 1 秒,以显示发送的响应。

    j(".form-horizontal").live("submit", function(){
            j.post(this.action, j(this).serialize(), function(){
                //this callback is executed upon success full form submission close modal here
    
            }, "script");
         //this is to wait 1 second until close
            setTimeout(function() {j('.modal').modal('hide');}, 1000);          
            return false;
        });
    

    【讨论】:

      猜你喜欢
      • 2012-12-20
      • 1970-01-01
      • 1970-01-01
      • 2018-05-28
      • 2019-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多