Using member groups and member fields in umbraco 6?
Hello,
I'm trying to access some things in my membership in my new Umbraco 6 project. I have a member logged into my front end. I want to check his Member roles and I also want to display a field I added to the member type (called firstName).
I'm digging around, this is probably super simple so if someone can pitch it I would appreciate it very much!
Now how about member groups. So for example, I know that the user I'm login in with is in a member group called "Site A".
if (Membership.ValidateUser(model.Username, model.Password))
{
// var member = Member.GetCurrentMember(); // var firstName = member.getProperty("firstName");
// Check if the user is in the member group var member = Membership.GetUser(model.Username);
if (...) { FormsAuthentication.SetAuthCookie(model.Username, false); }
// ... }
So basically, I want to allow the user to login only if he's in the appropriate member group. (This is in a multi-site setup.)
Thanks for the help!
Seb
Ohh looking forward to using that new API thx Jer!
Using member groups and member fields in umbraco 6?
Hello,
I'm trying to access some things in my membership in my new Umbraco 6 project. I have a member logged into my front end. I want to check his Member roles and I also want to display a field I added to the member type (called firstName).
I'm digging around, this is probably super simple so if someone can pitch it I would appreciate it very much!
Thanks!
Hi Sébastien
I think this is what you are looking for:
Member member = Member.GetCurrentMember();
member.getProperty("alias");
Regards
In v6.0 it's best to use Andreas his example. In v6.1 there will be a new member API: http://issues.umbraco.org/issue/U4-1659
More info here: http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-members
Jeroen
Ok reaching that property seems to work!
Now how about member groups. So for example, I know that the user I'm login in with is in a member group called "Site A".
So basically, I want to allow the user to login only if he's in the appropriate member group. (This is in a multi-site setup.)
Thanks for the help!
Seb
Ohh looking forward to using that new API thx Jer!
is working on a reply...