Copied to clipboard

Flag this post as spam?

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


  • Thomas M. Pedersen 11 posts 111 karma points
    Feb 14, 2023 @ 14:47
    Thomas M. Pedersen
    0

    Member properties

    I find it strange I can't get member property in umbraco 11.1.0 What am I doing wrong? I can return all other things on the member like email and normal fields, but not any member properties.

     var memberById = await _memberManager.FindByIdAsync("123");
     var test = memberById.TryGetPropertyValue<int>("propertyalias", 0);
    

    No matter what member property I try to get I get 0 as output. also, if i try HasProperty I get false.?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Feb 14, 2023 @ 15:47
    Huw Reddick
    100

    Hi Thomas,

    I think you now need to do this

    var memberById = await _memberManager.FindByIdAsync("123");
    IPublishedContent member = _memberManager.AsPublishedMember(memberById);
    var test = member.GetValue<int>("propertyAlias");
    
  • Thomas M. Pedersen 11 posts 111 karma points
    Feb 15, 2023 @ 12:43
    Thomas M. Pedersen
    0

    Cool Huw, Thank you.

    IPublishedContent member, solved my problem and I do this to get the property value:

    int test= (int)member.GetProperty("propertyAlias").GetValue();
    
Please Sign in or register to post replies

Write your reply to:

Draft