Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sébastien Richer 194 posts 430 karma points
    Feb 19, 2013 @ 01:07
    Sébastien Richer
    0

    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!

  • Andreas Iseli 150 posts 427 karma points
    Feb 19, 2013 @ 08:11
    Andreas Iseli
    0

    Hi Sébastien

    I think this is what you are looking for:

    Member member = Member.GetCurrentMember();
    member.getProperty("alias");

    Regards

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 19, 2013 @ 09:15
    Jeroen Breuer
    0

    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

  • Sébastien Richer 194 posts 430 karma points
    Feb 19, 2013 @ 15:13
    Sébastien Richer
    0

    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".

                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!

Please Sign in or register to post replies

Write your reply to:

Draft