Copied to clipboard

Flag this post as spam?

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


  • pat 124 posts 346 karma points
    Feb 08, 2017 @ 13:30
    pat
    0

    how to read customer property value added to member

    Hi all , I have added new field to Umbraco Member - text field call cRMAccount. After successful login i need to read value of this property which look like impossible (well cannot be)

    umbraco 4 I used to read this from Member class Member m = Member.GetCurrentMember(); and then m. getproperty("cRMAccount").value but in umbraco 7 I cannot find a way to do this.

    I tried to use ProfileModel but that return null value for memberprofile..

                            ProfileModel memberprofile = Members.GetCurrentMemberProfileModel();
                            string crmaccountid = ""; //  memberprofile.MemberProperties["cRMAccount"].Value.ToString();
    
                            if (memberprofile != null)
                            {
    
                                foreach (var p in memberprofile.MemberProperties)
                                {
                                    if (p.Name == "cRMAccount")
                                    {
                                        crmaccountid = p.Value;
                                        Session.Add("myicaccountid", crmaccountid);
                                        break;
                                    }
                                }
                            }
    

    any one know how to do this please... I might get same problem when i am creating members via sign up as well , so basically looking for a method to read and write custom property to members

  • pat 124 posts 346 karma points
    Feb 08, 2017 @ 13:50
    pat
    101

    Hi all , just found answer my self explained here because I am using surfacecontroller i need to use Services.MemberService

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

       var member =      Services.MemberService.GetByUsername(model.Username);
    string crmaccountid = (member.Properties["cRMAccount"] != null ) ? member.Properties["cRMAccount"].Value.ToString() : "";
    
  • 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