• Resolved omichon

    (@omichon)


    Hello,
    I would like to add a checkbox to my contact form on a multilingual web site.

    I tried the function described in this thread :

    but I can’t figure out how to adapt it for a multilingual site where the checkbox could be different values.

    I tried something like this :

    function my_wpcf7_use_mail_2_or_not( $additional_mail, $cf ) {
    	if ( "Send me a copy" != $cf->posted_data['send_copy'][0] ) {
    		$additional_mail = array();
    		}
    	elseif ( "Envoyez-moi une copie" != $cf->posted_data['send_copy'][0] ) {
    		$additional_mail = array();
    		}
    	return $additional_mail;
    }

    or like this :

    function my_wpcf7_use_mail_2_or_not( $additional_mail, $cf ) {
    	if ( "Envoyez-moi une copie" != $cf->posted_data['send_copy'][0] || "Send me a copy" != $cf->posted_data['send_copy'][0] )
    		$additional_mail = array();
    	return $additional_mail;
    }

    But without success.

    Any help would be appreciated.

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter omichon

    (@omichon)

    I finally find a way to do it with this code :

    function my_wpcf7_use_mail_2_or_not( $additional_mail, $cf ) {
    	if ( "" == $cf->posted_data['send_copy'][0] )
    		$additional_mail = array();
    	return $additional_mail;
    }

    That was quite simple, but not that much for the newbie I am.

    Thread Starter omichon

    (@omichon)

    The code from my previous post doesn’t work anymore because of some changes in v3.9 (WPCF7_ContactForm object no longer has a posted_data property.). Any help to adapt this code for v3.9 would be welcome.
    Thanks in advance.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Thread Starter omichon

    (@omichon)

    Thanks for the link. I was able to point out the issue from reading it, but I am unable to adapt the new code to my function. I am just a real newbie to php ??

    Thread Starter omichon

    (@omichon)

    Just had to try harder. All is fine again ??

    Hi.
    Tell me how to alter the code for the new version. I’m new to wp.

    Thread Starter omichon

    (@omichon)

    I changed the previous code like this :

    function my_wpcf7_use_mail_2_or_not( $additional_mail, $cf ) {
    $cf = WPCF7_Submission::get_instance();
    if ( $cf ) {
    	$posted_data = $cf->get_posted_data();
    }
    
    	if ( "" == $posted_data['send_copy'][0] )
    		$additional_mail = array();
    
    	return $additional_mail;
    }

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Contact form 7 send me a copy multilingual’ is closed to new replies.