Skip Navigation

[Closed] check if current user is logged in – Bug

This support ticket is created 4 years, 8 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 4 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1582677

I am trying to show hide element dependitly if user is logged in inside a views loop. Normally there is no issue with it, but since the last update i begin to noticed even on my older sites (where it used to work), that the conditional shortcode for logged in users is not working..

i tried both following conditionals:

 [wpv-conditional if="( '[wpv-current-user info='role']' eq 'administrator' )"]
Logged in 0
[/wpv-conditional]

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'true' )"]
Logged in 1
[/wpv-conditional]

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

[wpv-conditional if="( '[wpv-current-user info='login']' eq 'true' ) "]
Logged in 3
[/wpv-conditional]

Nothing is working!!

#1583391

Hi, if you simply want to test whether or not the current site visitor is a logged-in User or not, either of these should be effective:

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

If those two shortcodes are not working as expected, please add debug="true" to the shortcodes and test again:

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

Please share the output from these debug tests in your next reply.

This conditional would only work if you are logged-in as an administrator with no other secondary user roles:

[wpv-conditional if="( '[wpv-current-user info='role']' eq 'administrator' )"]
Logged in 0
[/wpv-conditional]

If you are logged-in as administrator and your admin User has no other User roles, please add debug="true" to the conditional and test again. Share the results in your next reply.

[wpv-conditional if="( '[wpv-current-user info='role']' eq 'administrator' )" debug="true"]
Logged in 0
[/wpv-conditional]

The info="login" in this context is not the login status, it is the username - also known as the user's login. So this conditional cannot help you determine login status except for one User with username "login".

[wpv-conditional if="( '[wpv-current-user info='login']' eq 'true' ) "]
Logged in 3
[/wpv-conditional]

One thing to note: debug information will never appear for Guest users, so it is useless for testing Guest scenarios.

The topic ‘[Closed] check if current user is logged in – Bug’ is closed to new replies.