Skip Navigation

[Gelöst] Help with conditional output

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
Help with conditional output

Solution:
The user has not setup the conditional shortcode correctly.

You can find proposed solution in this case with the following reply:
https://toolset.com/forums/topic/help-with-conditional-output/#post-2311855

Relevant Documentation:

This support ticket is created vor 10 Monate, 3 Wochen. 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
- 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 2 Antworten, has 2 Stimmen.

Last updated by daveG-7 vor 10 Monate, 3 Wochen.

Assigned support staff: Minesh.

Author
Artikel
#2311671

I'm trying to using conditional output to show or hide some information based on two different user fields from the post's author. One of them works, the other doesn't.

The one that works is:
[wpv-conditional if="( [types usermeta='public-phone-user' user_is_author='true'][/types] ne '' )"] - the content after that and before [/wpv-conditional] shows if there's something in the public-phone-user field, and doesn't show if it's empty.

However, the very similar conditional:
[wpv-conditional if=" ( [types usermeta='public-email-user' user_is_author='true' output='raw'][/types] ne '' )"] doesn't work - the content after it and before [/wpv-conditional] doesn't show whether or not there's anything in the public-email-user field.

Debugging that conditional shows the following when there is info in the field (in this case an actual email address which I've replaced with REDACTED:

####################
wpv-conditional attributes
####################
Array
(
[if] => ( REDACTED ne '' )
[debug] => true
)

####################
Debug information
####################
--------------------
Original expression: ( REDACTED ne '' )

and the following when there isn't:

####################
wpv-conditional attributes
####################
Array
(
[if] => ( ne '' )
[debug] => true
)

####################
Debug information
####################
--------------------
Original expression: ( ne '' )
--------------------

#2311855

Minesh
Supporter

Languages: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please try to use the following code and try to resolve your issue:

[wpv-conditional if=" ( '[types usermeta='public-email-user' user_is_author='true' output='raw'][/types]' ne '' )"] 
doesn't work - the content after it and before 
[/wpv-conditional] 

The issue seems that you did not wrap the Types shortcode with single quotes as shown below:

'[types usermeta='public-email-user' user_is_author='true' output='raw'][/types]' 

At first sight it seems to me that will be the fix but if it does not work please get in touch with me.

#2312463

That worked perfectly - thanks!