Echo自定义响应消息,在发送电子邮件挂钩

时间:2017-10-25 18:28:52

标签: php wordpress contact-form-7

我想在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;
    }

请帮忙

1 个答案:

答案 0 :(得分:5)

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

试试:

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


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


    return $response;

});
相关问题