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?
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?
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
Hi Kresten,
It is possible to get a member using the member id.
You can make a XSLT-file and use this Umbraco Extension
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
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?
I haven´t worked with usercontrols in Umbraco yet,
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
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?
Hi Kresten
You can go like this:
Member m = new Member(MemberId);
/Simon K
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...
Hi Kresten
Will this not give you the id that you neeed?
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.
/Jan
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
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
We can get User details by Id using the following code.
To get current User
UmbracoContext.UmbracoUser or UmbracoContext.Current.UmbracoUser
is working on a reply...