Get the Current User Name

Sherry Collins asked on June 3, 2015 17:57

I need to get the current user logged into my website. I thought I was getting it with Eval("NodeOwner"), but that is returning the person who wrote the blog. What would give me who is logged in.

Thanks.

Correct Answer

Brad Vrudney answered on June 3, 2015 22:45

the hash is the signed macro. Kentico does that for security purposes so it knows who created it, and what permissions it has. I think your issue may be that you are using {%%} which is for text transformations, rather than ascx. try changing it to: <%CurrentUser.UserName%>

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brad Vrudney answered on June 3, 2015 18:24 (last edited on December 10, 2019 02:30)

{%CurrentUser.UserName|(identity)GlobalAdministrator%}

You can also expand it to other properties:

<%# GetUserFullName(Eval<int>("UserID")) %>

https://docs.kentico.com/display/K8/Reference+-+Transformation+methods

1 votesVote for this answer Mark as a Correct answer

Sherry Collins answered on June 3, 2015 21:16 (last edited on December 10, 2019 02:30)

I get very strange results back in my Json string when I use this {%CurrentUser.UserName|(identity)GlobalAdministrator%} data-blogposttitle="<%# Eval("DocumentID")%>"><a href="#"><%#GetBlogLikesCount(Eval<int>("DocumentID"))%> Likes</a></span></div>

Am I doing something wrong?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.