Copied to clipboard

Flag this post as spam?

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


  • Glen 36 posts 168 karma points
    Sep 24, 2016 @ 02:56
    Glen
    0

    Can't access some member prop.

    Hi,

    I'am trying to update a member which has a property Name, Email and a custom properties etc.. and here I display some prop.

    enter image description here

    I use MembershipHelper How do I access the other prop? I want to update it programmatically.

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    Sep 24, 2016 @ 09:43
    Marc Goodson
    0

    Hi Glen

    There's a bit of overlap with the Membership services and helpers in Umbraco, but I tend to use the MembershipHelper if I need to display Member content in my site, and then use the MemberService if I want to update a particular Member's properties.

    https://our.umbraco.org/documentation/reference/management/services/memberservice

    var memberService = Services.MemberService;
    

    The Memberservice has GetById, GetByEmail & GetByUsername methods that return a Member object,

    var myMember = memberService.GetByEmail("[email protected]");
    

    you can then set properties on this object using

    myMember.SetValue("propertyAlias", "valueToSet")
    

    and you can save that change to the database using the MemberService

    memberService.Save(myMember);
    

    You can set the member's password using:

    memberService.SavePassword(myMember,"password");
    

    regards

    Marc

  • Glen 36 posts 168 karma points
    Sep 26, 2016 @ 01:47
    Glen
    0

    Hi marc,

    Thanks for the quick response I'm using template how do I access my custom props in member and also I'm using razor?

    enter image description here

    What did I missed?

    enter image description here

    but this one it work.

    enter image description here

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies