WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Contact Form 7] Send me a copy of message (13 posts)

  1. lionhurt
    Member
    Posted 2 years ago #

    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

  2. lyvyoo
    Member
    Posted 2 years ago #

    ...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?

  3. lionhurt
    Member
    Posted 2 years ago #

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

  4. Takayuki Miyoshi
    Member
    Posted 2 years ago #

    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".

  5. lionhurt
    Member
    Posted 2 years ago #

    thanks Takayuki Miyoshi

    it work great thank you so much

  6. lyvyoo
    Member
    Posted 2 years ago #

    ...and thanks lionhurt. Also work great :)

  7. lionhurt
    Member
    Posted 2 years ago #

    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;
    }
  8. Takayuki Miyoshi
    Member
    Posted 2 years ago #

    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;
    }
  9. lionhurt
    Member
    Posted 2 years ago #

    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;
    }
  10. Takayuki Miyoshi
    Member
    Posted 2 years ago #

    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;
    }
  11. lionhurt
    Member
    Posted 2 years ago #

    thank you very much Takayuki Miyoshi

    great plugin, great support

    thank you again

  12. tmbreuker
    Member
    Posted 1 year ago #

    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?

  13. tmbreuker
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic