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
    0

    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

    Kresten

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 04, 2010 @ 21:56
    Dennis Aaen
    0

    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.

    Reards

    Dennis Aaen

     

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

    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 4500 posts 18255 karma points admin hq c-trib
    May 04, 2010 @ 22:33
    Dennis Aaen
    0

    I haven´t worked with usercontrols in Umbraco yet,

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 04, 2010 @ 22:54
    Dirk De Grave
    2

    Kresten,

    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

     

    Cheers,

    /Dirk

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

    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
    1

    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
    0

    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 11280 posts 23678 karma points MVP 11x admin c-trib
    May 16, 2010 @ 21:56
    Jan Skovgaard
    1

    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?

    m.Id

    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.

    /Jan

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

    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?

    Regards,

    Kresten

  • Kevin Farrow 46 posts 67 karma points
    May 17, 2010 @ 23:33
    Kevin Farrow
    0

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

    umbraco.cms.businesslogic.member;

    ...

       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;

    Regards,
    Kevin

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

    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:

Draft