Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > My Account button when user is authenticated View modes: 
User avatar
Member
Member
kelements - 4/18/2011 7:26:03 PM
   
My Account button when user is authenticated
How do I create a webpart that shows a "My Account" button only when a user is logged in? Thanks in advance!

User avatar
Certified Developer 9
Certified Developer 9
Petar Kozjak - 4/19/2011 9:30:21 AM
   
RE:My Account button when user is authenticated
Create ascx page based on this: http://devnet.kentico.com/docs/devguide/index.html?developing_web_parts.htm

Add your button, setup visible to false, and add this in code behind:

        if (CMS.CMSHelper.CMSContext.CurrentUser.IsAuthenticated())
{
you button.Visible = true;
}


There is another quick way.... :)

Add Static HTML WebPart... inside add you link and in WebPart properties setup Display to roles, to display it to roles you want...

Hope this gives you idea...

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 4/19/2011 12:11:40 PM
   
RE:My Account button when user is authenticated
Hello,

You can also use a macro on the Visible property of your web part:

{%currentuser.username|(equals)public|(truevalue)false|(falsevalue)true%}

This macro returns true, if the user name isn't public, otherwise it returns false.

Best regards,
Boris Pocatko

User avatar
Member
Member
kelements - 4/19/2011 1:27:17 PM
   
RE:My Account button when user is authenticated
Thanks Petar, works great.