ravravrav
Member
Posted 6 months 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?
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
ravravrav
Member
Posted 6 months 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?
ravravrav
Member
Posted 6 months 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?