Skip Navigation

[Resolved] Conditional display based on empty custom field on author’s user record

This thread is resolved. Here is a description of the problem and solution.

Problem:
Conditional display based on empty custom field on author's user record

Solution:
you can use the Types shortcode with your conditional statement to check the custom field value that belongs to the specific author.

you can find the proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/conditional-display-based-on-empty-custom-field-on-authors-user-record/#post-1122576

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/#checking-types-plugin-shortcodes

This support ticket is created 6 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.

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

Last updated by emmaM-2 6 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#1122257

I have custom post type called "Listing" and custom fields on Users.

In the Content Template for Listings, I am trying to implement a conditional output based on whether a User custom field (on the author's user record) is populated or not. The custom field on the user record is called "usermemberlogo".

This is my code so far:
[wpv-conditional if="( $(wpcf-usermemberlogo) ne '' )"]
[types usermeta='usermemberlogo' title='%%TITLE%%' alt='%%ALT%%' size='medium' resize='proportional' user_is_author='true'][/types]
[/wpv-conditional]

How can I adapt this so that the conditional looks at the user record for the author of the post?

Thanks

Emma

#1122576

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - you can use the same Types shortcode with your conditional statement.

Could you please try the following code and try to resolve your issue.

[wpv-conditional if="( '[types usermeta='usermemberlogo' output='raw' user_is_author='true'][/types]' ne '' )"]
[types usermeta='usermemberlogo' title='%%TITLE%%' alt='%%ALT%%' size='medium' resize='proportional' user_is_author='true'][/types]
[/wpv-conditional]

More info:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/#checking-types-plugin-shortcodes

#1122646

Thanks Minesh, really appreciate it. My issue is resolved now.