Echo Custom response message , contact form 7 before send email hook

六眼飞鱼酱① 提交于 2021-02-08 06:48:56

问题


I want to show a custom message below or above contactform7, without sending the email. I tired it using before_send_email function, but nothing is working. below is the function I have used.

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

Please help


回答1:


to return a custom message on the form submission, you can use the filter wpcf7_ajax_json_echo

try that :

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


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


    return $response;

});


来源:https://stackoverflow.com/questions/46939659/echo-custom-response-message-contact-form-7-before-send-email-hook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!