Contact7 Check Boxes line breaks when submitted
I am working on a wordpress Contact7 Form with a checkbox selection. I am wondering if there is a way when these checkboxes are submitted via email that the format is changed so instead of coming up
item1, item2, item3
it comes up
item1
item2
item3
I found this post, but the code does not seem to be working
Add Line Break/Remove Commas for Checkbox options sent via Email from Contact Form 7
Its the exact same thin I am trying to do. I just wonder if contact7 updated something so that this code no longer works. Anyone able to get the following code working on the latest contact7.
add_filter('wpcf7_mail_tag_replaced', 'format_chackbox',10,4);
function format_chackbox($replaced, $submitted, $is_html, $mail_tag){
//you can check if this is the right field if need be.
if('my-checkbox-field' != $mail_tag-field_name()) return $replaced;
//$submitted contains the raw submitted data.
//$replaced is the formatted data, you can use either.
$a = explode(',', $replaced);
//check if you have multiple values and the email accepts html (set with the use html checkbox in the mail notification settings).
if(is_array($a) $is_html){
$replaced = 'ul'.PHP_EOL;
foreach($a as $v) $replaced .= 'li'.trim($v).'/li'.PHP_EOL;
$replaced .= '/ul'.PHP_EOL;
}
return $replaced;
}
Topic plugin-contact-form-7 Wordpress
Category Web