Skip Navigation

[Resolved] Conditional display based on user status not working

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

Problem:
How to check user role using [wpv-conditional] statement

Solution:
[wpv-current-user] shortcode outputs the information about the current, "logged-in" user.

You can find suggested solution with the following reply:
https://toolset.com/forums/topic/conditional-display-based-on-user-status-not-working/#post-401065

Relevant Documentation:
https://toolset.com/documentation/views-shortcodes/#wpv-current-user

This support ticket is created 7 years, 11 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.

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

Last updated by gaborG 7 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#401008

I want to make a condition based on whether the user is not logged in (he has a 'guest' role) or is logged in (his role is Subscriber or higher).
I tried to use this code but apparently it doesn't work:

[wpv-conditional if="( '[wpv-current-user info='role']' ne 'guest' )"]
User's profile displays here.
[/wpv-conditional]

[wpv-conditional if="( '[wpv-current-user info='role']' eq 'guest' )"]
Registration form and login displays here.
[/wpv-conditional]

The problem with this code is that it displays the first condition either way.
What am I doing wrong?

#401065

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

[wpv-current-user] shortcode outputs the information about the current, "logged-in" user.
https://toolset.com/documentation/views-shortcodes/#wpv-current-user

I think you should try following code:

[wpv-conditional if="( '[wpv-current-user info='role']' ne '' )"]
User's profile displays here.
[/wpv-conditional]
 
[wpv-conditional if="( '[wpv-current-user info='role']' eq '' )"]
Registration form and login displays here.
[/wpv-conditional]

I hope this will help you to resolve your issue.

#401068

That worked, thanks.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.