Dynamic account name and normal text for not logged in user


I’ve read this link, but I could not solve my problem.
Getting Details of the Logged In User and Binding them to your page

I would like to show “account name” from database when the user logged in, and also “GUEST” when the user is not logged in.

Show/hide doesn’t seem to work for this case. how can I solve this?


You can use ternary operator.

{{userdetails.data.query1[0].name ? userdetails.data.query1[0].name : 'Guest'}}

Thank you so much, I did this though, even “Guest” doesn’t appear on the side bar.

It should be shown like this


Well something is not right with your getuserdata server action … it returns validation messages.
All you need inside it is a security provider and a query filtered by it. No POST vars, no validation etc. please make sure to follow the tutorial.


Thank you so much, when I copied some server action, I didn’t erase what I didn’t need…the problem is solved!

1 Like