Copied to clipboard

Flag this post as spam?

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


  • Steven McLintock 12 posts 56 karma points
    Jul 14, 2014 @ 20:52
    Steven McLintock
    0

    Retrieve a member property in Umbraco 7

    Hi,

    I'm currently trying to retrieve a custom property value for a member (e.g. "City (city), Type: Textstring"). The user can successfully login, however I'm unable to retrieve any of their information?

    The error I'm receiving on the below code is "The property "city" is not recognised".

    @ {
         var memberService = Membership.GetUser();
         var profile = System.Web.Profile.ProfileBase.Create(memberService.UserName);
         string memberCity = profile["city"].ToString();
         // string memberCity = profile.GetPropertyValue("city").ToString();
    }
    

    Thanks for any help!

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 14, 2014 @ 21:35
    Dennis Aaen
    0

    Hi Steven,

    I am not a backend developer, but I would try to help you anyway.

    What if you are doing it this way, did it make any difference.

    @ {
    var memberService = Membership.GetUser();
         var profile = System.Web.Profile.ProfileBase.Create(memberService.UserName);
         string memberCity = profile.getProperty("city").value;
    }

    Hope this helps,

    /Dennis

  • Steven McLintock 12 posts 56 karma points
    Jul 14, 2014 @ 23:01
    Steven McLintock
    0

    Hi Dennis,

    Unfortunately your suggestion didn't work. I get alerted that getProperty is not a recognised property.

    Thanks,

    Steven.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 14, 2014 @ 23:04
    Dennis Aaen
    0

    Hi Steven,

    Does it any difference if you use GetProperty instead of getProperty

    Like this:

    @{
         
    var memberService =Membership.GetUser();
         
    var profile =System.Web.Profile.ProfileBase.Create(memberService.UserName);
         
    string memberCity = profile.GetProperty("city").value;
    }

    Or you could try this too.

    @{
         
    var memberService =Membership.GetUser();
         
    var profile =System.Web.Profile.ProfileBase.Create(memberService.UserName);
         
    string memberCity = profile.GetPropertyValue("city");
    }

    Hope this helps,

    /Dennis

  • Steven McLintock 12 posts 56 karma points
    Jul 14, 2014 @ 23:14
    Steven McLintock
    0

    Hi again,

    I actually tried "GetPropertyValue" and this appeared to work, however I get the error message "The settings property 'city' was not found." It's almost as if Umbraco doesn't realise I have set this property set up. It's definitely in against the member type "Member".

    Do I need to select "Member can edit" in the member type perhaps? Or "Show on profile"?

    Thanks,

    Steven.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 14, 2014 @ 23:27
  • Steven McLintock 12 posts 56 karma points
    Jul 15, 2014 @ 13:47
    Steven McLintock
    0

    Hi Dennis,

    Thanks, the first post you suggested worked!

    Thanks again, Steven.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 15, 2014 @ 15:55
    Dennis Aaen
    0

    Hi Steven,

    Great you got it to work. Please mark this as solved you have a green tick over each post, and if you click the green tick on the post that give you the solution, then you have mark this questions as solved.

    So people with the same problem can see what worked for you. In this case you should mark my first post as the solution.

    /Dennis

  • Steven McLintock 12 posts 56 karma points
    Jul 15, 2014 @ 15:57
    Steven McLintock
    0

    No problem Dennis,

    I don't suppose you could take a look at this post?

    http://our.umbraco.org/forum/umbraco-7/using-umbraco-7/54547-Update-a-member-property-in-Umbraco-7

    Thanks, Steven.

Please Sign in or register to post replies

Write your reply to:

Draft