…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?
you can check mail(2)
and write your second email
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”.
thanks Takayuki Miyoshi
it work great thank you so much
…and thanks lionhurt. Also work great 🙂
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;
}
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;
}
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;
}
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;
}
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.