• Hi,

    I was looking into “how do I sent the form to an own service” and realized it the following way:

    add_action( 'wpcf7_mail_sent', 'wpcf7_mail_sent_function' );
    
    function wpcf7_mail_sent_function( $contact_form ) {
    
        // Avoid sending an email
        $contact_form->skip_mail = true;
    
        // With the title I could do some check for the form...
        $title = $contact_form->title();
    
        // Get the form data
        $submission = WPCF7_Submission::get_instance();
        $formData= $submission->get_posted_data();
    
        // Now do some things with the form data
        / ...
    
        return false;
    }

    Now, when I add the form to some page and fill it, I always get this answer:

    {"mailSent":true,"into":"#wpcf7-f6-p2-o1","captcha":null,"message":"Thank you for your message. It has
     been sent."}

    Well always means of course if I pass a valid email etc. but I really wonder how to influence the response message and mailSent attribute based on some own logic (e.g. considering the response of my webservice), which tells me if something is wrong.

    I tried very hard to work with some filters like wpcf7_form_response_output but wasn’t really able to get it working and I also did not find any working example that changed the result. Probably there are a lot of modules where I could look into but I tried and did not suceed so far, maybe I can get an idea here.

    Thank’s in advance,
    Marcus

    https://ww.wp.xz.cn/plugins/contact-form-7/

The topic ‘Set result from hook wpcf7_mail_sent’ is closed to new replies.