Copied to clipboard

Flag this post as spam?

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

  • Kresten Banke 36 posts 56 karma points
    May 04, 2010 @ 21:30
    Kresten Banke

    Get member by ID

    Hey all,

    It is possible to get a member with various keys such as username, email etc.

    Isn't it possible to get the member using the member ID?

    Kind regards


  • Dennis Aaen 4368 posts 17679 karma points admin hq c-trib
    May 04, 2010 @ 21:56
    Dennis Aaen

    Hi Kresten,

    It is possible to get a member using the member id.

    You can make a XSLT-file and use this Umbraco Extension

    umbraco.library:GetMember(Int 32 MemberId) 

    Then you will get a member by an ID

    I haven´t try it myself, but hopefully it will solve your problem.


    Dennis Aaen


  • Kresten Banke 36 posts 56 karma points
    May 04, 2010 @ 22:23
    Kresten Banke

    Thanks - I'm a total newbe on xslt and I need to fetch the member from a usercontrol.

    Is there any way to do that?

  • Dennis Aaen 4368 posts 17679 karma points admin hq c-trib
    May 04, 2010 @ 22:33
    Dennis Aaen

    I haven´t worked with usercontrols in Umbraco yet,

  • Dirk De Grave 4496 posts 5826 karma points MVP 3x admin
    May 04, 2010 @ 22:54
    Dirk De Grave


    there's two options:

    - use the member api, some docs can be found here

    - use the membership api. A great overview can be found on the wiki




  • Kresten Banke 36 posts 56 karma points
    May 04, 2010 @ 23:18
    Kresten Banke

    Thanks - as I wrote I have found various methods for getting a member - i.e. by email, username etc.

    However, I store a memberID in a DB and want to be able to fetch the member using this key. Is that possible, or should I use a different key - such as username?

  • Simon Kibsgård 62 posts 73 karma points
    May 16, 2010 @ 21:16
    Simon Kibsgård

    Hi Kresten

    You can go like this: 

    Member m = new Member(MemberId);

    /Simon K

  • Kresten Banke 36 posts 56 karma points
    May 16, 2010 @ 21:26
    Kresten Banke

    Hi Simon,

    That will give me a new member, but I doens't allow me to access properties of the member with ID = x.

    Instead of saving the memberID in my db, I guess I'll just save the username - though it isn't the best solution...

  • Jan Skovgaard 10761 posts 21147 karma points MVP 4x admin c-trib
    May 16, 2010 @ 21:56
    Jan Skovgaard

    Hi Kresten

    Will this not give you the id that you neeed?

    m = Member.GetCurrentMember();

    Then you should be able to fetch the ID by using this line, right?


    Please do note that I'm no .NET wizard but I just played a bit around with this and seems to me like it's working.


  • Kresten Banke 36 posts 56 karma points
    May 17, 2010 @ 22:54
    Kresten Banke

    Hi - It's seems that I haven't explained the problem well enough.

    I need to store information about a purchase. One information data about who has actually purchase an item. I store the memberID in a db in order to fetch the member - and related properties - again. I would like to use the ID as a key for fetching the member since this is an integer an easy to use with linq/sql.

    However, when I want to fetch information about the "buyer", how can I do this, when all I have is the ID?

    Currently - as a work-aroung - I am storing both the ID and the loginname, since it is possible to fetch the member by loginname. However, this isn't very pretty...

    Any solutions for fetching a member from the memberID?



  • Kevin Farrow 44 posts 65 karma points
    May 17, 2010 @ 23:33
    Kevin Farrow

    i think you'll find Simon is correct...



       Member m = new Member(memberId);

    i.e. new Member(memberId) doesn't create a new member, it gets the Member's details using the memberId you pass in.

    if you need to create a new member then you would use:

    Member m = Member.MakeNew(...);

    or to get the current member (as Jan says):

    Member m = Member.GetCurrentMember().Id;


  • Abdul Rahim 21 posts 83 karma points
    Apr 20, 2015 @ 08:46
    Abdul Rahim

    We can get User details by Id using the following code.

    new umbraco.BusinessLogic.User(0)


    To get current User

    UmbracoContext.UmbracoUser or UmbracoContext.Current.UmbracoUser
Please Sign in or register to post replies

Write your reply to: