Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bex 444 posts 555 karma points
    Jun 08, 2011 @ 18:09
    Bex
    0

    Current UserId and Role

    Hi!

     

    Quick question as can't seem to find the answer after lots of searching...

    Can I get the current userID and current user Role in xslt without having to create an extension?

     

    Thanks

    Bex

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 08, 2011 @ 18:56
    Tom Fulton
    0

    Hi Bex,

    You can get a lot of the member's properties using umbraco.library:GetCurrentMember() :

    <xsl:value-of select="umbraco.library:GetCurrentMember()/@loginName"/>

    But unfortunately I don't believe there is any way to get Role information without creating an extension.  However creating XSLT Extensions are super simple now with 4.7 (see Tim's blog post).  The function you'd need to return this info is:  System.Web.Security.Roles.GetRolesForUser(loginName)

    Hope this helps,
    Tom

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 08, 2011 @ 19:08
    Tom Fulton
    0

    Oh!  It looks like uComponents already has an extension for this:  GetGroupsByMemberId(Int32)

    See:  http://ucomponents.codeplex.com/wikipage?title=Members&referringTitle=Documentation

    -Tom

  • Bex 444 posts 555 karma points
    Jun 09, 2011 @ 09:39
    Bex
    0

    Thanks Tom! :) That's brilliant! I knew there was something, I just couldn't find it in the documentation!

Please Sign in or register to post replies

Write your reply to:

Draft