Support » Plugin: Contact Form 7 » [Plugin: Contact Form 7] Where do I add a hook to be executed before a mail is sent?

  • I am using Contact Form 7 to send an email whenever someone wants to contact me. It works great. Now I’d also like to create a contact in a db whenever someone tries to contact me.

    From what I read, I created a function which does this and the function works (tried calling it in a static file). But I cannot understand where to add the function call. I added this statement to functions.php in the plugin’s admin folder

    add_action('wpcf7_before_send_mail', 'myFunction');

    But the function is not called. I even tried adding it to classes.php but it doesn’t get called from there either. The function is as follows

    function myFunction($cf7){
        $firstName = $cf7->posted_data["first_name"];
        $lastName = $cf7->posted_data["last_name"];
        $emailAddr = $cf7->posted_data["email"];
        $companyName = $cf7->posted_data["company"];
        $urlAddr = $cf7->posted_data["URL"];
        $designation = $cf7->posted_data["title"];
    
        //add data to the database here
    }

    Would really appreciate some help. I do not know about wordpress development so cannot be certain if I’m adding the action at the right place.

    Thanks.

    http://wordpress.org/extend/plugins/contact-form-7/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Contact Form 7] Where do I add a hook to be executed before a mail is sent?’ is closed to new replies.