问题
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