Copied to clipboard

Flag this post as spam?

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


  • Joe May 6 posts 26 karma points
    Mar 09, 2011 @ 15:44
    Joe May
    0

    Accessing info about a member by node ID

    Hello,

    I've been searching around for a good while now, and most of the info I am finding seems to pertain to the older membership model. I am using Umbraco 4.7 and ASP.NET membership.

    Overall what I'm trying to do is simple: create a usercontrol that allows a person logged in and in the admin member group the ability to edit the profiles of others. To do this, I need to do a seemingly super simple task: create a list of users by name (real name, not username).

    I've created custom params for the user type (aliases firstName and lastName), and after doing some digging thought that I might be able to access this info by node ID. For example:

    Dim Member As MembershipUser = System.Web.Security.Membership.GetUser(RoleMembers(x))
    Dim MemberID As Integer = CInt(Member.ProviderUserKey)
    Dim MemberNode As New Node(MemberID)
    Dim FirstName As String = MemberNode.GetProperty("firstName").Value

     

    (RoleMembers() is just an array of usernames that we are iterating through)

    However, this returns the following error: "No published item exist with id 1080"

    And yet, here it is:

    I've also read about creating a derivative of the Profile base, editing web config, etc, however this seems like a complicated solution to a simple problem, and it only seems to work for accessing the properties of the user currently logged in, not an arbitrary user.

    Any suggestions are greatly appreciated. Maybe I'm totally in the wrong direction on this, but it does seem to me like this should be simple, so I assume I'm missing something.

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Mar 09, 2011 @ 16:18
    Hendy Racher
    0

    Hi Joe,

    Instead of using the umbraco.presentation.nodeFactory.Node class you'll want to use the umbraco.cms.businesslogic.member.Member class.

    Dim Member As MembershipUser = System.Web.Security.Membership.GetUser(RoleMembers(x))
    Dim MemberID As Integer = CInt(Member.ProviderUserKey)
    Dim MemberNode As New Member(MemberID)
    Dim FirstName As String = MemberNode.getProperty("firstName").Value

    HTH,

    Hendy


  • Joe May 6 posts 26 karma points
    Mar 09, 2011 @ 16:26
    Joe May
    0

    Hendy,

    That worked perfectly. Thank you sir.

Please Sign in or register to post replies

Write your reply to:

Draft