Copied to clipboard

Flag this post as spam?

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

  • Ayo Adesina 424 posts 1006 karma points
    Feb 01, 2021 @ 13:39
    Ayo Adesina

    Getting a Strongly Typed Umbraco Member

    I have added a few extra properties to my umbraco member definition and I am using the Models Builder.

    The model generation is working perfectly.

    But how do I get a strongly typed version of the Member.

    I have tried.

    var member = memberService.GetByEmail(email) as Member; < Ends up being null 
    var member = (Member)memberService.GetByEmail(email);  < casting exception 
  • Ayo Adesina 424 posts 1006 karma points
    Feb 01, 2021 @ 14:16
    Ayo Adesina

    Managed to solve it.... like this:

    var memberMe = memberService.GetByEmail(email);
    var test = Umbraco.Member(memberMe.Key) as Member;

    test is now a strongly typed Member with all the properties.

  • Nik 1517 posts 6705 karma points MVP 5x c-trib
    Feb 01, 2021 @ 14:32

    Hi Ayo,

    As an FYI, that is the correct way to achieve what you are after and the reason is this:

    The MemberService is interacting with the Database, and the Membership Helper (which is Umbraco.Member) is interacting with the Published Cache.

    The other thing to note about it is that the "Critical" properties on a member, I don't believe, are available via the strongly typed member because they related to an Identity not your custom profile/properties bits.



Please Sign in or register to post replies

Write your reply to: