How to show content only for logged users

henrik

New member
XNullUser
Joined
Jul 26, 2022
Messages
2
Reaction score
0
Points
1
NullCash
7
Had spent some time trying to show content only if user is logged or not, there is a paid module to make it easier but i figured out.

In any .tpl file you can use:
{if $customer.is_logged} **CONTENT** {/if}

you can also use ! before $ to use if customer is not logged like:

{if !$customer.is_logged} **CONTENT** {/if}

It might be easy for those who already know more about prestashop but i struggled a lot for it, so there it is.
 

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,542
Reaction score
1,535
Points
113
NullCash
4,194
Had spent some time trying to show content only if user is logged or not, there is a paid module to make it easier but i figured out.

In any .tpl file you can use:


you can also use ! before $ to use if customer is not logged like:



It might be easy for those who already know more about prestashop but i struggled a lot for it, so there it is.
It is easy for all who understand basic coding. Those operators are very same in most languages!
And you should read forum rules but I think it does not matter anymore!
 

henrik

New member
XNullUser
Joined
Jul 26, 2022
Messages
2
Reaction score
0
Points
1
NullCash
7
Thanks for your contribution, didn't stuggled with operators, but with objects and classes specific from Prestashop. Also i have read the forum rules and don't see how this contribution would be interfering into something, if you think so please specify where and we can remove this post, just tried to help :)
 

d-shilko

Well-known member
☆☆ Special ☆☆
☆ Pro ☆
Joined
Jun 10, 2021
Messages
2,542
Reaction score
1,535
Points
113
NullCash
4,194
Thanks for your contribution, didn't stuggled with operators, but with objects and classes specific from Prestashop. Also i have read the forum rules and don't see how this contribution would be interfering into something, if you think so please specify where and we can remove this post, just tried to help :)
If you attentively read the rules you should know for questions and tips we have the Request thread.

you can also use ! before $ to use if customer is not logged like
!- operator not
$ - operator variable
.......

It was a good forum. And I see you like Prestashop as most of the good members on this forum.
If you need help - feel free to ask me :)


Have a good coding!
 
Top