Access CurrentUser from javascript

joyanta sen asked on August 7, 2018 23:06

Hi, Could anyone please let me know how to access CurrentUser from the javascript(written in Master page)?

Thanks, Joyanta

Recent Answers

Brenden Kehren answered on August 7, 2018 23:23

You can use the javascript webpart and output the information in a script block using a macro. Your macro would be something like:

<script type="text\javascript">
  var currUserID = {%MembershipContext.AuthenticatedUser.UserID%};

I don't know if you can assign the {%MembershipContext.AuthenticatedUser%} object to a js variable if it will keep the object structure or not but worth a try I guess.

0 votesVote for this answer Mark as a Correct answer

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