I want to display data based on user preference indicated by a checkbox. (Email, phone, etc)
Original custom field: hidden link
I tried this:
[wpv-conditional if="( $(wpcf-contact-preference) eq 'Email' )"][types field='company-email'][/types][/wpv-conditional]
I tried a conditional block with the same.
If I use NOT or 'ne', the display works. So is there something wrong with my syntax of the conditional?
hidden link
Hello,
I have tried it in my localhost with a fresh WP installation + the latest version of Toolset plugins, the codes you mentioned above works fine.
Please make sure the "Email" option value is: Email
See my screenshot email-value.JPG
Thank you, That is how it looks: hidden link
I see the issue. There are 3 choices. The user can select all 3 preferences if they want to be contacted in all three ways. But only the first value will shows when all 3 are selected.
If all 3 are selected, only Phone shows. If Phone is not selected and Email and Internal Messaging are ticked, only 2nd choice will show conditionally. How can I make all three conditionals appear when all 3 are selected?
[wpv-conditional if="( $(wpcf-contact-preference) eq 'Phone' )"]Phone: [types field='company-phone'][/types][/wpv-conditional]
[wpv-conditional if="( $(wpcf-contact-preference) eq 'Email' )"][types field='company-email' output='raw'][/types][/wpv-conditional]
[wpv-conditional if="( $(wpcf-contact-preference) eq 'Internal Messaging' )"]xxxxxxxxxx[/wpv-conditional]
Thanks for the details, you can try the Types shortcode with attributes "option" + "state", like this:
[types field="contact-preference" option="0" state="checked"]Email: ...[/types]
[types field="contact-preference" option="1" state="checked"]Phone: ...[/types]
[types field="contact-preference" option="2" state="checked"]Internal Messaging: ...[/types]
More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes
Works great! Documentation is really helpful.
My issue is resolved now. Thank you!