【问题标题】:Echo Custom response message , contact form 7 before send email hookEcho 自定义响应消息,发送电子邮件挂钩前的联系表 7
【发布时间】:2019-01-09 02:21:17
【问题描述】:

我想在contactform7下方或上方显示自定义消息,而不发送电子邮件。我使用 before_send_email 函数厌倦了它,但没有任何效果。下面是我用过的函数。

add_action("wpcf7_before_send_mail", "wpcf7_do_something_else");  
    function wpcf7_do_something_else($cf7) {
        $wpcf->skip_mail = true;
        // Here I tried to use jquery or wordpress filter function to display custom message. but nothing is displaying.
        return $wpcf;
    }

请帮忙

【问题讨论】:

  • $wpcf7->skip_mail = true 什么也没做,因为你一开始还没有定义那个对象。

标签: php wordpress contact-form-7


【解决方案1】:

要在表单提交时返回自定义消息,您可以使用过滤器wpcf7_ajax_json_echo

试试看:

add_filter("wpcf7_ajax_json_echo", function ($response, $result) {


    $response["message"] = "a custom message";


    return $response;

});

【讨论】:

  • 您应该在注册过滤器时添加10, 2。否则,第二个参数 $result 将永远不会传递给您的过滤器,并且会引起通知。
  • 或者,只需省略 $result(未使用)。
猜你喜欢
  • 2019-05-28
  • 2015-10-11
  • 2013-08-06
  • 2012-07-05
  • 2018-05-16
  • 1970-01-01
  • 1970-01-01
  • 2018-12-07
  • 2018-05-09
相关资源
最近更新 更多