• Resolved lionhurt

    (@lionhurt)


    i want create select drop down menu have yes/no values
    to send the message to the same email in the form

    [email* email]
    [select sendcopy "no|" "yes|[email]"]

    how to get this work ,
    or any idea

Viewing 12 replies - 1 through 12 (of 12 total)
  • lyvyoo

    (@lyvyoo)

    …And if is possible, please be more explicit with this problem – I want to recive a copy because in my situation, the message from the form go to a friend email adress. I want to be announced every time when somebody has sent the message with the form.

    If I write another email adress (my adress) separated with comma, in the Mail/To section, I will receive a copy of the message? So the form can send simultaneously the message at two email addresses?

    Thread Starter lionhurt

    (@lionhurt)

    you can check mail(2)
    and write your second email

    Takayuki Miyoshi

    (@takayukister)

    lionhurt, add this code to your theme’s functions.php:

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

    and alter the select tag to this:

    [select sendcopy "no" "yes"]

    then your Mail(2) will be active only when you select “yes”.

    Thread Starter lionhurt

    (@lionhurt)

    thanks Takayuki Miyoshi

    it work great thank you so much

    lyvyoo

    (@lyvyoo)

    …and thanks lionhurt. Also work great 🙂

    Thread Starter lionhurt

    (@lionhurt)

    Takayuki Miyoshi

    how can i get this work with checkbox i try :

    [checkbox send_c “Send Copy”]

    function my_wpcf7_use_mail_2_or_not( $additional_mail, $cf ) {
    	if ( isset($cf->posted_data['send_c']) )
    		$additional_mail = array();
    
    	return $additional_mail;
    }
    Takayuki Miyoshi

    (@takayukister)

    function my_wpcf7_use_mail_2_or_not( $additional_mail, $cf ) {
    	if ( "Send Copy" != $cf->posted_data['send_c'] )
    		$additional_mail = array();
    
    	return $additional_mail;
    }
    Thread Starter lionhurt

    (@lionhurt)

    Takayuki Miyoshi
    not work

    my codes
    [checkbox send_c default:1 "Send me a copy of this message"]

    add_filter( 'wpcf7_additional_mail', 'my_wpcf7_use_mail_2_or_not', 10, 2 );
    
    function my_wpcf7_use_mail_2_or_not( $additional_mail, $cf ) {
    	if ( "Send me a copy of this message" != $cf->posted_data['send_c'] )
    		$additional_mail = array();
    
    	return $additional_mail;
    }
    Takayuki Miyoshi

    (@takayukister)

    Sorry. $cf->posted_data['send_c'] is an array in this case.

    add_filter( 'wpcf7_additional_mail', 'my_wpcf7_use_mail_2_or_not', 10, 2 );
    
    function my_wpcf7_use_mail_2_or_not( $additional_mail, $cf ) {
    	if ( "Send me a copy of this message" != $cf->posted_data['send_c'][0] )
    		$additional_mail = array();
    
    	return $additional_mail;
    }
    Thread Starter lionhurt

    (@lionhurt)

    thank you very much Takayuki Miyoshi

    great plugin, great support

    thank you again

    Hi guys,
    I followed this discussion and I’d also like to implement the checkbox on my contactform. However, if I add this to the form:

    [checkbox send_c default:0 "Send me a copy of this message"]

    and this in the functions.php of my theme:

    add_filter( 'wpcf7_additional_mail', 'my_wpcf7_use_mail_2_or_not', 10, 2 );
    
        function my_wpcf7_use_mail_2_or_not( $additional_mail, $cf ) {
    	if ( "Send me a copy of this message" != $cf->posted_data['send_c'] )
    		$additional_mail = array();
        return $additional_mail;
    }

    and then open the contactform in my browser, tick the checkbox and send the form. I don’t receive a copy. What am I doing wrong?

    found it! I ticked the Mail(2) option and then it works like a charm.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: Contact Form 7] Send me a copy of message’ is closed to new replies.