Contact Form 7 – “Send me a copy” Checkbox

UPDATE: The following code no longer works as of CF7 v3.9 as the author has changed how wpcf7_before_send_mail() works. Here is an updated guide for v3.9+ written by Max Pohlenz

Contact Form 7 is a highly customizable and widely used WordPress plugin (at the time of writing there have been 24,137,767 downloads); We currently have 67 of our 98 WordPress sites with this plugin installed.

I recently had a client request a checkbox field for “Send me a copy of this message” which, when checked, should send the user their own copy of the form submission. This is not an entirely uncommon request and luckily, CF7 is pretty well-developed and allows developers to extend the plugin via filters.

The following shows the end result; a checkbox in which the user can choose to send a copy of the form to themselves as well as the set recipient:

 add_filter( 'wpcf7_additional_mail', 'dc_wpcf7_send_self_copy', 10, 2 );
 
 function dc_wpcf7_send_self_copy( $additional_mail, $cf ) {
       if ( 'yes' != $cf-> posted_data['copymyself'] )
             $additional_mail = array();
       return $additional_mail;
 }

Add that as either a plugin or in your child theme functions.php file.

Next, load up your form in the admin area.

Create your checkbox using [checkbox copymyself "Send me a copy of this message"] – It is important you use the same name as you checked for in the function above (in this case, “copymyself”) or this will not work.

IMPORTANT: Mail(2) needs to be turned on in CF7 settings area.

4 comments

  1. Dear Sir/Mam,

    Hope you are doing well!

    I am Ailsa, a Digital Media expert by profession. I explore your website and came to know that you are alarmed with bringing new customers and losing business to your competitors!

    Offer me to analyze and figure out the factors that your website is losing from Search Engine Aspects, and take vital steps to bring back more customers and sales.

    My complete Analysis will give you clear insights for:

     Why your website rank behind of your competitors?

     How to get enough Organic Traffic and Sales?

     Strategy to get huge customers through Social Media.

     Guarantee First Page ranking on Search Engines.

     Getting business though Mobile Optimization.

    After your confirmation, I would be glad to provide you with further details or Digital Marketing Proposal of your website, and then fix a time to speak with you over the phone or Skype.

    Eagerly awaiting for your quick response.

    Thanks & Regards
    Ailsa Conway
    Business Development Manager
    Email: ailsaconway.02@gmail.com
    0.2

    P.S: – This is our marketing strategy to use a Gmail account. Once you reply us back, we will communicate with you through our corporate Email ID.

    Kindly ignore the mail, if doesn’t fit your requirement, this is a bulk mailer. Any inconvenience caused will be highly regretted.

Leave a Reply

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