raygulick
Member
Posted 2 years ago #
I love CF7; very flexible and clean. I recently, however, had a need to create a very long form with very few required fields. A blank line in the email is created for each unfilled field and, due to the number of fields, this sometimes creates very long blank spaces in the email and a lot of scrolling to get to the bottom.
Is there some way to remove these blank lines from the email?
http://wordpress.org/extend/plugins/contact-form-7/
It's easy if you utilize 'wpcf7_mail_components' filter. Add these lines into the functions.php in your active theme:
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;
}
raygulick
Member
Posted 2 years ago #
That sounds great! Thanks! Was this info available in the docs and I just missed it?
That's good.
Was this info available in the docs and I just missed it?
No, it's not in docs. I just wrote it for your demand as it's not that difficult.
raygulick
Member
Posted 2 years ago #
I really appreciate your help. Worked beautifully, BTW.
raygulick
Member
Posted 2 years ago #
I made a donation. Well-supported plugins deserve donations from time to time. Thanks again.