Contact Form 7
Run a function before sending post (5 posts)

  1. ravravrav
    Posted 4 years ago #

    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?

  2. Takayuki Miyoshi
    Plugin Author

    Posted 4 years ago #

    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

  3. ravravrav
    Posted 4 years ago #

    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?

  4. ravravrav
    Posted 4 years ago #

    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?

  5. galtzhayek
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic