Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm having a problem that seems like it should be easy but it's not.
Using the Umbraco API, I've just created a member. I want to use member ID as a foreign key in some tables for another app I've built. But I'm having a very difficult time getting this value; or more generally, the umbraco.cms.businesslogic.member.Member object.
There are a bunch of deperecated methods like Member.GetMemberFromLoginName() that would probably work, but I don't want to used deprecated things. And I don't want to use login name in case that changes - numerical ID seems better.
It's trivial to get this for the logged-in member via member.getcurrentmember(), but I can't find a way to do it for an arbitrary or not-yet-logged-on member.
There's a good chance I'm missing something obvious here, so all suggestions are welcome.
Using Umbraco 4.5.2 by the way - planning to upgrade soon.
Would this work, or am I off track?
Member m = Member.GetCurrentMember();int memberid = m.Id;
Yep, it works just fine for the logged-in user; the problem is with another user where you know the login name but need the ID.
In this case, it's in the 'create user' wizard - I'm making a custom registration page and I want to put the member id of the newly-created user into some other database tables that are part of a different app.
You can make a call to the GetMemberByLoginName() method:
which is more generic and uses the membership provider specified in web.config.
Dirk, that's exactly it, thanks.
Bo, Member.GetMemberByLoginName(username) works too, but VS tells me it's deprecated, so I was looking for a more durable solution.
Bit late in the day but for anyone else looking for this in 2018:
var member = Membership.GetUser(model.Email);
int memberId = (int) member.ProviderUserKey
This will get you the nodeId of the recently created member
That is so helpful! Thanks!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted