Skip Navigation

[Résolu] Conditional logic to check if a user is logged in or not

This support ticket is created Il y a 9 mois et 3 semaines. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

Ce sujet contient 1 réponse, a 2 voix.

Dernière mise à jour par Waqar Il y a 9 mois et 3 semaines.

Assisté par: Waqar.

Auteur
Publications
#2676704

Tell us what you are trying to do?
I am migrating a site from Genesis to Generatepress. I have working code in a footer widget in the genesis version of the site which conditionally checks to see if the user is logged in or not, and presents either a link to the login screen, or a personalised welcome message with a link to their "My Account" page.
I cannot get this to work in the generatepress site footer block.

The basis of my original conditional code:

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'false' )"]
You are not logged in.
<a href="link/to/my-account-page">Login</a>[/wpv-conditional]

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'true' )"]
Welcome, [wpv-user field="user_login"]
View <a href="link-to/my-account/">"My Account"</a> page
[wpv-logout-link]Log out[/wpv-logout-link]
[/wpv-conditional]

I have tried adding this as a custom html block, and tried recreating it using shortcode blocks, etc,.
I've also tried to rebuild the conditionality in the block editor version of toolset.

This thread suggests an alternative string to use in the conditional block editor, but the solution doesn't work for me.
https://toolset.com/forums/topic/condition-check-whether-user-is-logged-in-or-not/

What is the link to your site?
The current working site (on genesis) is lien caché

Grateful if you can point me in the right direction

#2676767

Hi,

Thank you for contacting us and I'd be happy to assist.

Sometimes, content/block sections from other themes or plugins don't support the use of shortcodes within shortcodes.

To workaround this you can try creating a Toolset content template, put the original working conditional code in that and then load this content template in the Generatepress site footer block, through a single shortcode:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body )


[wpv-post-body view_template="Template name" suppress_filters="true"]

I hope this helps and please let me know if you need further assistance.

regards,
Waqar

#2676777

That did the trick for me, thank you!

Alan a confirmé que le problème avait été résolu sur 2024-01-01 09:09:32.
Ce ticket est maintenant fermé. Si vous êtes un client de Toolset et que vous avez besoin d'aide, veuillez ouvrir un nouveau ticket d'assistance