• When my user hits ‘send’ I would like to run a function before sending anything.

    A brief explanation of the function; it will take the address, geocode it to get the lat/lng and then compare against a mysql table to find the closest match.

    Any idea how I can implement this?

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

    (@takayukister)

    wpcf7_before_send_mail action hook is available for that purpose.

    This topic also helps:
    Insert contact name and email in database after successful submission

    Thread Starter ravravrav

    (@ravravrav)

    Thanks for that, I’ve taken a look at the link. This seems pretty explanatory:

    add_action( 'wpcf7_before_send_mail', 'my_conversion' );
    
    function my_conversion( $cf7 )
    {
    $email = $cf7->posted_data["your-email"];
    $name = $cf7->posted_data["your-name"];
    insert_newsletter_subscriber($email, $name);
    }

    So am I right to think this works as when the user hits send, it will activate the hook and run function my_conversion. And then, the email will get sent as per usual?

    Thread Starter ravravrav

    (@ravravrav)

    What if I want to pull some data from my database and add it on to the end of the email, then send it – how do I do that?

    got stuck with the same issue, did u solve it?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Contact Form 7] Run a function before sending post’ is closed to new replies.