How to hook into Contact Form 7 Before Send

Contact Form 7 is the most used plugin in WordPress for the contact us page, Once upon a time this plugin was used only to send emails o websites or business owners, but now it’s used for advanced levels, If you have any project that required user advance data, or if you are using it to real state listing page, where website owner need to from which listing page query is coming, for that, You can use Contact Form 7 for advance level and you can mention listing title or others data to contact form 7 form details. also, you can just store submitted data to the database and skip the Email.

Method 1: Hook into Contact Form 7 before sending The Email

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;

if you want to Skip sending emails, you can just make skip_mail true, as well can do store data in the database or you can take action based on user data.

Method 2: Add Hook After Sending Email

   add_action('wpcf7_mail_sent', 'after_sent_mail'); 

   function after_sent_mail($wpcf7)


       // put desired code here


you can handle all data after sending it by email by using this action hook.

You need to put code in your theme function.php file, make sure you know how PHP code works, otherwise don’t touch the code. it will brack your theme. and the website will be put down. there is more tutorial about contact form .7 ,  please check it out. if you are still confused about this code please let us know in a comment below.