Copied to clipboard

Flag this post as spam?

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


  • Chris Roberts 74 posts 106 karma points c-trib
    Sep 15, 2014 @ 20:31
    Chris Roberts
    0

    Get Umbraco User Details in Umbraco v6.1.6

    I am writing a backoffice extension for Umbraco v6.1.6.

    I want to record details of who has done what from within my extension. So - I am retrieving the ID of the currently logged in user with the following code, and storing this in my database table...

    int CurrentUserId = UmbracoContext.Current.UmbracoUser.Id;

    What I now need to do is retrieve a user's name from a given ID (so that when someone else logs in to the backoffice, they can see who else did things).

    I've had a look in the Umbraco source but it looks like the UserService is 'internal'. Could someone point me in the right direction, please?!

    Many thanks!
    - Chris

     

  • Tom van Enckevort 107 posts 429 karma points
    Sep 15, 2014 @ 21:34
    Tom van Enckevort
    0

    Would UmbracoContext.Current.UmbracoUser.Name give you the required user's name?

  • Chris Roberts 74 posts 106 karma points c-trib
    Sep 15, 2014 @ 23:04
    Chris Roberts
    0

    Hi Tom,

    Thanks for your reply - but that will only give me the name of the current user. What I need to do is get the name of any user from their ID.

    Thanks,
    - Chris

  • Chris Roberts 74 posts 106 karma points c-trib
    Sep 21, 2014 @ 18:25
    Chris Roberts
    0

    Still looking for a solution to this if anyone can help!?

     

    Thanks,
    - Chris

  • Tom van Enckevort 107 posts 429 karma points
    Sep 21, 2014 @ 19:28
    Tom van Enckevort
    100

    You should able to initialize a user using their ID:

    var user = new umbraco.BusinessLogic.User(userId);
    user.Name;
    

    This will not create a new user, but get the existing user from the database.

  • Chris Roberts 74 posts 106 karma points c-trib
    Sep 24, 2014 @ 16:46
    Chris Roberts
    0

    That looks to have done the trick!

    Great help - thank you!
    - Chris

Please Sign in or register to post replies

Write your reply to:

Draft