1
votes

IN my contact form 7 field are available in that some field are not mandatory. when i put blank this field in email label of field is included. (check below email format):

Name : bhavin

address : address1

phone no :

Email address : [email protected]

...

Required format : when i dont enter value in phone no field at this time below email format send to email id

Name : bhavin

address : address1

Email address : [email protected]

...

How it is possible..?

1
for this, I think you need to customize in contact form 7 pluginKhushboo
@Khushboo : yes that i tryed. but still dont get any idea. where i have to changeBhavin Solanki
I don't even understand the question, could you explain a little better?shish
yes,if you blank field in form which is not compulsory then it will not display in mail body label as well null valueBhavin Solanki
Try adding this code into functions.php: add_filter( 'wpcf7_mail_components', 'remove_blank_lines' ); function remove_blank_lines( $mail ) { if ( is_array( $mail ) && ! empty( $mail['body'] ) ) $mail['body'] = preg_replace( '|\n\s*\n|', "\n\n", $mail['body'] ); return $mail; }shish

1 Answers

1
votes

Yes that is running perfectly because if field not required then no value need to send email, here blank email will send to administrator on given mail id from backend.