Skip Navigation

[Resolved] Showing an icon if a user meta multiple checkbox field contains a specific value

This support ticket is created 5 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 5 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1214935

I am trying to output a series if icons depending on the value of a usermeta field which is a multiple checkbox entry.

For example, the first checkbox option for the field named "activity" is called "presenter" and if checked contains the string "presenter". I want to test for this value an output an icon (say presenter.jpg) if the value is selected (checked).

I can't see any specific documentation on usermeta but have adapted from a custom post type solution as follows:

[wpv-conditional if="('[types usermeta='activity' option='0'][/types]' eq 'presenter' )"]
<img src="hidden link">
[/wpv-conditional]

but this doesn't work.

#1215251

Hello,

I assume we are talking about a custom checkboxes user field "activity" created with Types plugin.

I have tried it in my localhost, your codes works just fine.

Please check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) Display the "activity" user field directly, for example, if you are going to use current logged-in user as condition, you can use below shortcode:
[types usermeta='activity' option='0' user_current='true'][/types]

Check if it displays the value "presenter" correctly, then use above shortcode as condition of [wpv-conditional] shortcode, and test again.

3) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2019, and test again

#1216492

Thanks a lot. I now realise I had been slightly stupid and forgotten that my field values have a capital letter at the beginning, so "Presenter" not "presenter". Code works perfectly now.

#1216684

Thanks for sharing the solution.