Copied to clipboard

Flag this post as spam?

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

  • Brendan Rice 501 posts 915 karma points
    Apr 07, 2022 @ 00:07
    Brendan Rice

    How do you add member property value to a member in v9

    Need to add custom properties to a member and populate them via code.

    How can you do this in v9?

  • Ambert van Unen 169 posts 781 karma points c-trib
    Apr 07, 2022 @ 08:12
    Ambert van Unen

    Well the properties are set in the backoffice (just like documenttypes), but in code you can do this.

    You first need to get the alias of the field, if you're using modelsbuilder you can do it like this:

    var customMemberProperty = Member.GetModelPropertyType(_publishedSnapshotAccessor, x => x.CustomMemberProperty).Alias;

    or just use the string alias of the field, in this case "customMemberProperty".

    Then get the member by various means (email or id for example)

    var memberToUpdate = _memberService.GetByEmail(emailAddress);

    Then update the values:

    memberToUpdate.SetValue(customMemberProperty, "NewValue");

    And save them



Please Sign in or register to post replies

Write your reply to: