Skip Navigation

[Resolved] wpv-conditional with CONTAINS operator

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 3 weeks, 5 days ago.

Assisted by: Minesh.

Author
Posts
#2779241
wpv-conditional-contains.png

Hi, I am trying to use a CONTAINS operator inside the wpv-conditional shortcode. Here's my example:
[wpv-conditional if="('[types usermeta='my-custom-user-checkboxlist' separator=', ' current_user='true'][/types]' CONTAINS '[wpv-post-taxonomy type='my-custom-post-taxonomy' separator=', ' format='slug']')"]...[/wpv-conditional]

Unfortunately that does not work. Is there a way to achieve that with the wpv-conditional shortcode? Please see my attached debug information.

#2779336

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Here is the Doc that shows information about how you can check the specific taxonomy term assigned:
- https://toolset.com/documentation/legacy-features/views-plugin/displaying-taxonomies-conditionally/#specific

Do you see above Doc helps and you can adjust the conditional shortcode as shown with the example:

[wpv-conditional if="( CONTAINS(#(foreign-language),'chinese') )"]
<p>This consultant speaks Chinese!</p>
[/wpv-conditional]
#2779343

Hi Minesh, thank you for this piece of information. I was able to do build my condition as follows:

[wpv-conditional if="( CONTAINS(#(ausbildungsmodul),'[types usermeta='user-ausbildungsmodule' option="0" current_user='true'][/types]') OR CONTAINS(#(ausbildungsmodul),'[types usermeta='user-ausbildungsmodule' option="1" current_user='true'][/types]') OR CONTAINS(#(ausbildungsmodul),'[types usermeta='user-ausbildungsmodule' option="2" current_user='true'][/types]') OR CONTAINS(#(ausbildungsmodul),'[types usermeta='user-ausbildungsmodule' option="3" current_user='true'][/types]') OR CONTAINS(#(ausbildungsmodul),'[types usermeta='user-ausbildungsmodule' option="4" current_user='true'][/types]') )"]<p>...</p>[/wpv-conditional]

This way I check if the post taxonomy contains a certain term which comes from a custom user field from the current_user. As this custom user field is a list of checkboxes I need to check each option with an OR operator. It works for me. One last question: Do you see a more elegant/shorter way to achieve this?

Regards, Christian

#2779346

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

No- there is no other workaround. Maybe another possible solution should be custom shortcode but again that you will need to write the custom shortcode code as per your requirement.

#2779351

Thank you for helping us!!!