Skip Navigation

[Fermé] 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 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.

This topic contains 4 réponses, has 2 voix.

Last updated by Luo Yang Il y a 7 années et 5 mois.

Assigned support staff: Luo Yang.

Auteur
Publications
#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

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

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

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Please let me know if you need more assistance for it

Le sujet ‘[Fermé] Conditional If/Else on custom values’ est fermé à de nouvelles réponses.