• I’m intercepting the email being sent using $abort = true; I want to display a custom message for that abort message.

    The related code looks like this…

    add_action('wpcf7_before_send_mail', 'wpcf7ev_verify_email_address', 10, 2);
    
    add_filter('wpcf7_display_message', function ($message, $status)
    {
        $submission = WPCF7_Submission::get_instance();
        if ($submission->is('abort'))
        {
            $message = __('Please check your email to verify your email address.', '');
        }
    
        return $message;
    }
    , 10, 2);
    
    function wpcf7ev_verify_email_address($wpcf7_form, &$abort)
    {
        // first prevent the emails being sent as per usual
        $abort = true;
    

    The email does get aborted, but the message is still ‘Sending mail has been aborted.’. I’m not sure if that filter is being called?

    What am I doing wrong with the wpcf7_display_message filter?

Viewing 1 replies (of 1 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Look at the code setting the status and message. The correct status is aborted, not “abort”. Also, you can use $submission->set_response() to set the response message (you can call it within the wpcf7_before_send_mail action callback). Use of wpcf7_display_message isn’t needed.

Viewing 1 replies (of 1 total)
  • The topic ‘Creating custom messages’ is closed to new replies.