checkbox: change separator between multiple choices
-
Hi,
I make a simple checkbox.
The shortcode [my-checkbox], shows multiple values like this:
value1, value2, value3How can I display [my-checkbox] without the commas separating the values ?
value1 value2 value3Is there a special shortcode, php code or other plugin addon for this ?
Thanks
-
You can change it with this technique: Customizing mail-tag replacement
hi Takayuki, thank you for your link…
Unfortunately, from that information I do not have the skills to do this:
make all checkbox mail tag output display as one string, not separated by comma.Can you please show me how to do this ? I am willing to do donation for this help.
So this
[my-checkbox]Would show as output one string, just separated by space, not comma
value1 value2 value3I use this for an API, and now [my-checkbox] only loads the first value when multiple checkboxes are checked ( the comma is the cause I guess ).
-
This reply was modified 5 years, 2 months ago by
booly66.
This code came to me while doing zazen. It’s not correct, the multiple values of [my-checkbox] are still separeted with a comma between them π
add_filter( 'wpcf7_mail_tag_replaced_checkbox', function( $replaced, $submitted, $html, $mail_tag ) { $replaced = str_replace(",","",$submitted); return $replaced; }, 10, 4 );In this case,
$submittedis an array.add_filter( 'wpcf7_mail_tag_replaced_checkbox', function( $replaced, $submitted, $html, $mail_tag ) { $replaced = implode(' ',$submitted); return $replaced; }, 10, 4 );I changed the code as you suggested, to transform the array into one string, but it does not work unfortunately.
Can you please point me further in the right direction ?
thankshi, any anwser on this issue ?
I need the same solution: the
[my-checkbox] arraytag should be converted into justone string value outputI have Googled the internet like crazy, but there is nowhere extensive documentation on how to achieve this.
Is it possible with CF7 or do I need another plugin ?
-
This reply was modified 5 years, 1 month ago by
jessy86.
Where can we see the website in question?
What content do you have in the Form tab panel?
this is the content I have in my Form tab panel.
Maybe I have to link the “checkboxes mail tag hook” to the checkbox code here ?<div class="col-md-6 row"><div class="form-group row"> <label for="inputEmail3" class="col-md-3 form-control-label">Naam*</label><div class="col-md-9">[text* text-name class:form-control ]</div></div> </div> <div class="col-md-6"><div class="form-group row"> <label for="inputEmail3" class="col-md-3 form-control-label">Bedrijf</label><div class="col-md-9">[text text-bedrijf class:form-control "Optioneel"]</div></div> </div><div style="clear:both;"></div> <div class="col-md-6 row"><div class="form-group row"><label for="inputEmail3" class="col-md-3 form-control-label">E-mail*</label><div class="col-md-9">[email* email-404 class:form-control]</div></div> </div> <div class="col-md-6 "><div class="form-group row"><label for="inputEmail3" class="col-md-3 form-control-label">Telefoon*</label><div class="col-md-9">[text* tel-915 class:form-control]</div></div> </div> <div style="clear:both;"></div> <div class="ikwens"><div class=" m-t-30"><p>Ik wens een vrijblijvend gesprek over:</p></div> [checkbox* interesse-27 "Totaalrenovatie" "Totaalrenovatie Aanbouw & Opbouw" "Totaalrenovatie Binnenhuis" "Totaalrenovatie Terras & omheining" "Andere"]</div> <div style="clear:both;"></div> <div class=""><div class="class=" m-t-30""><label for="inputEmail3" class="form-control-label extra-informatie-label">Extra informatie:</label><div>[textarea extrainfo-86 rows:6 class:form-control "Geef hier je bericht in aub"]</div><div style="clear:both;"></div></div></div> <div class=""><div class=" m-t-20"><p>Bel mij terug*:</p></div>[checkbox* belme-479 "in de voormiddag" "tijdens de middag" "in de namiddag" "s avonds" ] <div style="clear:both;"></div></div> <div class=""><div class="col-md-8 m-t-30" style="padding:0px;"><div class="form-group"><label for="inputEmail3" class="col-md-6 form-control-label last-field">Wanneer wens je de werken aan te vangen*:</label><div class="col-md-6">[text* your-date class:dp-field ]</div></div></div> </div> <div style="clear:both;"></div> <div class=""><div class=" m-t-30"><p>Jouw budget:</p></div>[select* menu-budget include_blank "<100.000" "100.000 - 200.000" "200.000 - 300.000" ">300.000" "nog niet gekend"] <div style="clear:both;"></div></div> <div style="clear:both;"></div> <div class=""><div class=" m-t-30"><p>Ik ken Renovatief verbouwen van:</p></div> [select menu-referral default:1 "---" "Facebook" "Instagram" "Website" "Youtube" "LinkedIn" "Google of andere zoekmachine" "Vrienden, Familie, Kennissen"] <div style="clear:both;"></div></div> <div class="col-md-8 m-t-30" style="padding:0px;"><div class="form-group">[acceptance your-consent] Ik ga akkoord met de <a href="https://www.renovatiefverbouwen.be/privacy-policy.html" target="_blank"><u>privacyverklaring</u></a> </div></div> [anr_nocaptcha g-recaptcha-response] <div class="col-md-8 m-t-30" style="padding:0px;"><div class="form-group">[submit class:btn class:btn-contactus "verzenden"]</div></div>You don’t have a
checkboxtag in the form. What you have ischeckbox*. So you need to change the filter hook to use.add_filter( 'wpcf7_mail_tag_replaced_checkbox*', function( $replaced, $submitted, $html, $mail_tag ) { $replaced = implode(' ',$submitted); return $replaced; }, 10, 4 );I added this to functions.php, changing the filter, it does not do anything at all π
Can you please look at my code, what’s wrong here ?
hi,
As the filter hook does not work at all, I was able to fix this bug with the following trick:
1/ I made a hidden text field
2/ with jQuery, all checkbox values are copied “live” into that field
3/ when the form is submitted, I have a[text-from-checkboxes]mail tag that works, with a spacing separator ( not the damn comma πjQuery(document).ready(function(){ jQuery(".ikwens input:checkbox").click(function() { var string = ""; jQuery(".ikwens input:checked").each(function() { string = string + ' ' + jQuery(this).val(); }); jQuery("input.text-interesse").val(string); }); }); -
This reply was modified 5 years, 2 months ago by
The topic ‘checkbox: change separator between multiple choices’ is closed to new replies.