Skip Navigation

[Geschlossen] Conditional If/Else on custom values

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created vor 9 Jahre, 12 Monate. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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 Antworten, has 2 Stimmen.

Last updated by Luo Yang vor 9 Jahre, 10 Monate.

Assisted by: Luo Yang.

Author
Artikel
#209425

I have been struggling with this for some time. Trying to display a profile image and if no image display some text. I have it displaying the image properly but when i use the if to display something else if it is empty i don't get what is expected.

For the case of this example I have the following.

If a profile image exists type "happy" if it does not type "grumpy"

Here is the code as I understand it from the documentation:

wpcf-user_profile_image is the custom field that i created. I have added the wpcf- as outlined because this is a custom value created by types.

When i use my custom value on the page the image value works fine
[types usermeta="user_profile_image" size="thumbnail" align="none" resize="proportional"][/types]

When i try to use it in an if statement it doesn't seem to work?

[wpv-if f1="wpcf-user_profile_image" evaluate="empty($f1)"]grump[/wpv-if]

[wpv-if f1="wpcf-user_profile_image" evaluate="empty($f1)" condition="false" ]happy[/wpv-if]

So when i execute i get all records showing as grumpy when i know that the fields user_profile_image is propagated.

So needless to say i am stuck on the conditional statement.

Any help or guidance would be much appreciated pulling my hair out. It is a private site so to view the live page please msg me.

Thanks much!

#209426
conditional_statement.png

I have added a screen capture to see the result i am getting. I should have all "happy" and only one record that is "grumpy"

Thanks again

#209461

Hi rogerw,

You are checking a custom user field, in this case please try this:

[wpv-if evaluate="'[types usermeta="user_profile_image" size="thumbnail" url="true"][/types]' = ''" debug="true"]grump[/wpv-if]

[wpv-if evaluate="'[types usermeta="user_profile_image" size="thumbnail" url="true"][/types]' = ''" condition="false" debug="true"]happy[/wpv-if]
#215777

Thank you sorry I missed the reply. I will review your suggestions and let this close if the issue is corrected.

#216331

Please let me know if you need more assistance for it

Das Thema „[Geschlossen] Conditional If/Else on custom values“ ist für neue Antworten geschlossen.