Navigation überspringen

[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 3 years, 9 months. 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.

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 -

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von daveG-7 vor 3 years, 9 months.

Assistiert von: 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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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!