Contact form 7 : addition of send me a copy option from front-end
As we know that contact from 7 is a very useful plugin to be used for addition of various types of form on a wordpress website. Here we are discussing about a situation when we want to add a checkbox at front-end to send the copy of mail on user’s choice.
If a user comes to website and he fill a form then generally mail sent to a mail id which we set it in admin “To” section, here we are adding the code to add a checkbox so that a user can check this and a copy will automatically send to user’s mail id.
To implement this, please follow below mentioned steps :
Step 1 : Just copy and paste below mentioned code to functions.php file of your current theme :
<?php add_filter( 'wpcf7_additional_mail', 'wpcf7_send_mail_to_self', 10, 2 ); function wpcf7_send_mail_to_self( $additional_mail, $cf ) { $cf = WPCF7_Submission::get_instance(); $posted_data = $cf->get_posted_data(); if ( "Send me a copy" != $posted_data['send_c'][0] ) $additional_mail = array(); return $additional_mail; } ?>
Step 2 : Add this to the form at back-end section, where we want to show the checkbox :
[checkbox send_c default:1 "Send me a copy"]
Note : Just copy and paste the short code we have created for filling the email in the form and paste it in “To” section of additional mail part.
Here we have done this part by using the above mentioned code. This is updated code which will work with the updated contact form 7.
Feel free to ask me your queries 🙂
It is really good to find code for Send me a copy option. Keep working hard.
Hello, I have just find this solution and I am wondering if I use a Child Theme if it’s enough to add the code in the Child theme’s functions.php?
Thank you for a short confirmation.
Yes, I have mentioned to add this code to your current theme’s functions.php file. In the case of child theme, you should add this to your child theme’s functions.php file and result will be the same.