Skip Navigation

[Resolved] Conditional output if user is logged in

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

Problem:
How to display conditional output using [wpv-conditional] shortcode and check if user is logged in

Solution:
Views offers [wpv-current-user] shortcode using which you can get the current logged in user information. You can use this shortcode with [wpv-conditional] shortcode to display conditional output.

Relevant Documentation:
=> https://toolset.com/documentation/views-shortcodes/#wpv-current-user
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This support ticket is created 8 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 philippeC 8 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#357620

Hi,

I want to display something only if the're is a logged in user.

I know it should be easy with a wpv-conditional shortcode, but i'm not sure how. I've tried this but it don't work.

[wpv-conditional if="('[wpv-current-user info='login']' eq '[true]')"]
my content
[/wpv-conditional]

Thank you

#357662

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Could you please try to use following code:

[wpv-conditional if="('[wpv-current-user info='id']' ne  '')"]
my content
[/wpv-conditional]

Please have look at following documentation that may help you:
=> https://toolset.com/documentation/views-shortcodes/#wpv-current-user
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#357836

The "ne" doesn't seem to work, but with a "eq" it does.

So with your links I've come up with those 2 shortcode that works.

[wpv-conditional if="('[wpv-current-user info='id']' eq '')"]
Logged off
[/wpv-conditional]

[wpv-conditional evaluate="false" if="('[wpv-current-user info='id']' eq '')"]
Logged in
[/wpv-conditional]

Thank you.

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