Skip Navigation

[Closed] Conditional Content if User Not Logged In

This support ticket is created 3 years, 1 month 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Shane 3 years ago.

Assisted by: Shane.

Author
Posts
#2228189

Can you tell me the best way to display a conditional block if a user is NOT logged in? I have tried the following, none of which seem to work:

1) If current user role = 'guest'
2) If current user role is blank
3) If current user ID = 0
4) If current user ID is blank

It would be nice if there were simply an option that said "if user logged in" but does not seem to exist. Thanks for any help.

-- Aaron

#2228223

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Aaron,

Thank you for getting in touch.

We actually do have a shortcode that can check the users logged in status. The shortcode you can use is [wpv-current-user info="logged_in"]

This shortcode will return true or false if the user is logged in or not. You can therefore use this in our conditional statement to check the status of the user.

Here is a simple example below.


[wpv-conditional if="('[wpv-current-user info='logged_in']' eq 'true' "]
Do something if logged in
[/wpv-conditional]

Please let me know if this helps.
Thanks,
Shane

#2228293
nothing-comes-up.PNG
not-logged-in-settings.PNG

Thanks. That is helpful, although it's still not working. Attached are two screenshots. I tried enabling debug mode but even that output does not appear. Does it being inside a widget have an impact? When I add the shortcode you provided as text inside a paragraph block it correctly displays "false" but it doesn't seem to have the desired effect inside the conditional block.

#2228349

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Aaron,

Based on your screenshot your use case is correct.

Would you mind allowing me to have admin access to the website so that I can have a more detailed look at this for you ?

Please where applicable please provide me with a link to an example page where I can see the issue.

I've enabled the private fields for your next response.

Thanks,
Shane

The topic ‘[Closed] Conditional Content if User Not Logged In’ is closed to new replies.