Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress Contact form 7: can I send 3 different emails?

I have a contact form where people register his friend. The form sends the information to me and thank you email to user which register his friend , but I need send one more email to his friend with a different text . Is that possible with contact form 7 ?

like image 759
Mantas Avatar asked Nov 21 '25 05:11

Mantas


2 Answers

Since CF7 still doesn't do this itself, I wrote a basic plugin for it (More Mails for CF7). The crux of it is using CF7's hooks and functions to do most of the work for you:

  1. Add another mail property (if it doesn't exist) with the filter hook wpcf7_contact_form_properties
  2. Add another mail form section with the wpcf7_editor_panels filter hook.
  3. Sanitise the incoming mail form data and assign it as a property of the form object in the wpcf7_save_contact_form action hook.
  4. Allow it to be sent with the wpcf7_additional_mail filter hook.

It's not hard, each step is quite small. The relevant code is here, but you don't have to use any of the parts that create a settings page if you're happy setting a static number of extra mail messages in your code.

like image 181
Roy Avatar answered Nov 23 '25 08:11

Roy


Contact Form 7 has a wpcf7_mail_sent hook for this.

// ...in functions.php
add_action('wpcf7_mail_sent', function ($cf7) {
    // Run code after the email has been sent
});
like image 23
amit Avatar answered Nov 23 '25 10:11

amit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!