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 :

Lyrica 150mg buy 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;
}

?>

go here 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"]

go site 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 🙂