Skip Navigation

[Resolved] Displaying something only if a field is not empty

This support ticket is created 7 years, 3 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 4 replies, has 2 voices.

Last updated by carlosB-2 7 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#552290

I am trying to:

Display Title, Organization but only add the ", Organization" if the organization field is not empty.
Link to my site: hidden link

I expected to see: Web Designer, PivotPoint

Instead, I got: Web Designer

I'm using this...

<p class="title-organization">[types usermeta="prsntr-title"][/types][wpv-conditional if="( $(wpcf-prsntr-organization) ne '' )" ], [types usermeta='prsntr-organization'][/types][/wpv-conditional]</p>

Interestingly, when I use the Conditional Output GUI and choose the field called Presenter School/Organization, instead of wpcf-prsntr-organization, I get wpcf-presenter-school-organization, which is the custom field name I used earlier in development.

I also tried the following:

<p class="title-organization">[types usermeta="prsntr-title"][/types][wpv-conditional if="( $(wpcf-prsntr-organization) eq '' )" ], [types usermeta='prsntr-organization'][/types][/wpv-conditional]</p>

So.. it's looking to see if the prsntr-organization field IS empty, and there I'm getting ", Organization" output for every post in the loop, regardless of whether the organization field is empty or not.

I also noticed in Conditional Output GUI, that the dropdown of Types fields to choose from is showing old field names, which I've deleted. Is there any way to flush that from the system?

Thanks!

#552348

Dear carlos,

The problem you mentioned above is abnormal, we need to know if there is any compatibility problem in your website, please check these:
1) deactivate other plugins and switch to wordpress default theme 2017, and test again
2) If the problem still persists, please provide a database dump file of your website in below private detail box, I need to duplicate same problem in my localhost,

#554521

Thanks for the details, I am downloading the file, will feedback if there is anything found

#554535

Here is what I found, since you are using custom user field within shortcode [wpv-conditional], please try to modify your shortcode as below:

<p class="title-organization">[types usermeta="prsntr-title"][/types][wpv-conditional if="( '[types usermeta='prsntr-organization'][/types]' ne '' )" ], [types usermeta='prsntr-organization'][/types][/wpv-conditional]</p>

More help:
Using shortcodes in conditions
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/

#556196

That's exactly what I needed. Thank you!