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.
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.
Getting member ID from login name or username
Hello,
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.
Hi Andrew
Would this work, or am I off track?
Nigel
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.
- Andrew
Hi Andrew,
You can make a call to the GetMemberByLoginName() method:
Member.GetMemberFromLoginName(string LoginName);
- Bo
Or
which is more generic and uses the membership provider specified in web.config.
Cheers,
/Dirk
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.
Thanks all,
- Andrew
Bit late in the day but for anyone else looking for this in 2018:
This will get you the nodeId of the recently created member
That is so helpful! Thanks!
is working on a reply...