How to hook into Contact Form 7 Before Send

Question :
Solution code for : How to hook into Contact Form 7 Before Send

How to hook into Contact Form 7 Before Send

I had to do this to prevent Email from being sent. Hope it helps.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
    Prevent the email sending step for specific form
*/
add_action("wpcf7_before_send_mail", "wpcf7_do_something_else"); 
function wpcf7_do_something_else($cf7) {
    // get the contact form object
    $wpcf = WPCF7_ContactForm::get_current();
 
    // if you wanna check the ID of the Form $wpcf->id
 
    if (/*Perform check here*/) {
        // If you want to skip mailing the data, you can do it... 
        $wpcf->skip_mail = true;   
    }
 
    return $wpcf;
}

No comments:

Post a Comment