Contact Form 7 – doing *something* when an email has been sent

April 16, 2014 | Time Savers, Troubleshooting, Wordpress | 0 comments

I love contact form 7, unlike a fair few others who have either purchased Gravity forms or who have gotten stuck using something like CForms which I really don’t get along with. I use it on every site I write and, with the new addition of the Flamingo plugin which, despite it’s infancy, has potential for the future, rarely find anything I can’t do with it. In this case I needed to perform a web service call when an email had been sent but couldn’t find an obvious way of doing so. So I dug into the code and found a way to do it which I thought I would share.

There is a handy action hook which does just what I needed called ‘wpcf7_mail_sent’ which I wrote a couple of lines for and it worked a treat. Hopefully someone else can find another use for this to save them getting into the code..

The code

add_action('wpcf7_mail_sent', 'hm_pixel_conversion');

function hm_pixel_conversion( &$args ) {
    //Web service call goes here
}

A Donate Button!

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

CommentLuv badge

About this site and Sean Barton

Picture of Sean
Sean Barton is a Freelance Website Developer in Crewe, Cheshire. He is a Full Stack Developer but with extensive experience in Wordpress and other Frameworks. He is the Co-Founder of SitePresser, Layouts Cloud and Page Builder Cloud among other things..
This site was set up in 2008 as a tutorial and scripting resource for the PHP language and Wordpress.
Find out more about Sean on the About Me page or use the Hire Me page to get in touch. For more information about Sean's work take a look at the Portfolio

SitePresser is the plugin that packages child themes and layout packs for sale. Works with Divi and Elementor.