Tell us what you are trying to do?
I have User Custom Fields as checkboxes. Each checkbox represents a business. When a checkbox is checked, a message for the specific business should appear. This works with only one checkbox, but if I choose 2 or more it breaks. Cannot find the documentation to enable ANY checkbox. Here is the code
[wpv-conditional if="( '[types usermeta='enabled_programs' separator=', ' current_user='true'][/types]' eq '[wpv-post-taxonomy type='company' format='slug']' )"]
<span class="enrolled-badge">[wpml-string context="wpv-views"]ENROLLED[/wpml-string]</span>
[/wpv-conditional]
I need it to display the ENROLLED message for each business checked.
Note how in the attached screenshot, one image displaying two busineeses (two checkboxes ticked from the user profile) is missing the label "ENROLLED" while the screen with only one business (only one checkbox ticked from user profile) shows the label
Hi,
Welcome to Toolset support. According to the documentation below you might be able to use the CONTAIN operator:
https://toolset.com/documentation/legacy-features/views-plugin/displaying-taxonomies-conditionally/
Example (adjust slugs and the number of options). Here company is your taxonomy; enabled_programs is the user checkboxes field:
[wpv-conditional if="(
CONTAINS(#(company),'[types usermeta="enabled_programs" option="0" current_user="true"][/types]')
OR CONTAINS(#(company),'[types usermeta="enabled_programs" option="1" current_user="true"][/types]')
OR CONTAINS(#(company),'[types usermeta="enabled_programs" option="2" current_user="true"][/types]')
/* add one OR branch per option you use in the user field */
)"]
<span class="enrolled-badge">ENROLLED</span>
[/wpv-conditional]
Notes:
- #(company) is the built-in macro that returns the current post’s company terms; CONTAINS is the documented way to check a specific term (see the “specific term” example).
Toolset
- [types usermeta="enabled_programs" option="N" …] outputs the value of option N if it’s checked, or empty if not.
For more information: https://toolset.com/documentation/customizing-sites-using-php/functions/
Thanks.