Saltar navegación

[Resuelto] Condition check whether user is logged in or not

This support ticket is created hace 3 años, 5 meses. 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 -

Zona horaria del colaborador: America/Jamaica (GMT-05:00)

Este tema contiene 5 respuestas, tiene 2 mensajes.

Última actualización por Shane hace 3 años, 5 meses.

Asistido por: Shane.

Autor
Mensajes
#2299789
Screenshot 2022-02-22 at 6.43.10 PM.png

Dear Sir/Madam,

I want to set the condition if user is logged in. Please advise how I can do.

#2299949

Shane
Colaborador

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Kelvin,

Thank you for getting in touch.

Based on your message you want to display something to only logged in users correct?

You conditional statement is contradicting this. Please clarify for me.

Thanks,
Shane

#2299975

Dear Shane,

I only show you where I want to enter the statement, could you please show me the correct statement that I can check whether the user is logged in or not ?

#2300021

Shane
Colaborador

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Kelvin,

If you want to check if the user is logged in you will check against their logged in status.

So the statement will be

  ( ( '[wpv-current-user info="logged_in"]' eq 'true' ) ) 

This will check if the current user is logged in.

Thanks,
Shane

#2300569

Dear Shane,

Your statement will auto be changed to

  ( ( '[wpv-current-user info="id"]' eq 'true' ) ) 

I tried below two statements but not work.

  ( ( '[wpv-current-user info="id"]' eq 'false' ) ) 

or

  ( ( '[wpv-current-user info="id"]' ne 'true' ) ) 
#2301105

Shane
Colaborador

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Kelvin,

The statements below should work. I went ahead and revised and tested both and they work on my end.

To display items to users who are logged out

  ( empty( '[wpv-current-user info="id"]') ) 

To display items to users who are logged in.

 NOT ( empty( '[wpv-current-user info="id"]') ) 

Please let me know if they both work for you.

Thanks,
Shane