Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Macro to check if user is logged in View modes: 
User avatar
Member
Member
gliker-inorbital - 9/1/2011 1:10:45 PM
   
Macro to check if user is logged in
Hi, what macro I can use to check if user is logged in and get true/false value? I want to hide login box webpart if user is already logged in.

Thanks

User avatar
Member
Member
gliker-inorbital - 9/1/2011 2:27:33 PM
   
RE:Macro to check if user is logged in
To clarify my previous post, website will have number of users. Some of them will be just normal members, and some will be editors and administrators. I want to add macro into "Visible" webpart field to hide login form from all those who are already logged in regardless what role they have.

User avatar
Kentico Support
Kentico Support
kentico_radekm - 9/1/2011 8:35:57 PM
   
RE:Macro to check if user is logged in
Hello.

I believe it can be done even without macro. You can simply set “Display to roles” property of given web part to “Not authenticated users.”

Best Regards,
Radek Macalik

User avatar
Member
Member
gliker-inorbital - 9/2/2011 8:04:17 AM
   
RE:Macro to check if user is logged in
Sweet, that worked! Thanks Radek.

User avatar
Member
Member
m.rutter - 9/2/2011 6:03:06 AM
   
RE:Macro to check if user is logged in
gliker-inorbital wrote: To clarify my previous post, website will have number of users. Some of them will be just normal members, and some will be editors and administrators. I want to add macro into "Visible" webpart field to hide login form from all those who are already logged in regardless what role they have.


Hello.
I'm sure my solution is not the best but just to let you know a different approach from setting the roles (maybe someone needs this in the future):

{%if (currentuser.userid == "65") { "<Anonymous>" } else { "<Registered>" }%}


Where 65 is the code of the Anonymous user in Kentico (I can't exclude it may change in the future).

I successfully used this solution in many cases.

Regards,
Marcello

User avatar
Member
Member
gliker-inorbital - 9/2/2011 8:06:15 AM
   
RE:Macro to check if user is logged in
Thanks Marcello!

I'll use this for those webparts without "Display to roles" properties.

Regards,
Giuliano