Copied to clipboard

Flag this post as spam?

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


  • DL 8 posts 98 karma points
    Feb 01, 2023 @ 09:35
    DL
    0

    Issue with updating custom member property

    Hello everyone :)

    I am having an issue updating a custom property field on a member.

    When i am creating a member i am doing the following:

    IMember member = _memberService.CreateMember(loginName, email, userName, "portalmember");
    member.SetValue("testName", "Testname");
    _memberService.Save(member);
    

    This works fine when the member is created:

    enter image description here

    However if I want to update this value, i am trying to do the following:

    public void UpdateMemberValue(string email)
    {
        if (!string.IsNullOrEmpty(email))
        {
            var member = _memberService.GetByEmail(email);
            member.SetValue("testName", "TestNameUpdated");
            _memberService.Save(member);
        }
    
    }
    

    But even after the code above has been executed, the value in backoffice is still the same - "Testname"

    Does anyone know, what I am missing here?

    I am running on version: Umbraco 10.2.0

  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Feb 01, 2023 @ 12:04
    Huw Reddick
    0

    Hi DL,

    That should work, are you seeing any errors/warnings in the Umbraco logs?

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Feb 02, 2023 @ 08:04
    Dave Woestenborghs
    0

    Hi DL,

    Do you see errors in your error log. Because I have similar code working without issues. The only thing I can think of is that the member can't be found by e-mail.

    Dave

  • Huw Reddick 1749 posts 6114 karma points MVP c-trib
    Feb 02, 2023 @ 08:25
    Huw Reddick
    0

    or perhaps it is returning more than one member, I don't think member emails are unique by default

  • DL 8 posts 98 karma points
    Feb 02, 2023 @ 09:58
    DL
    0

    Hi Huw and Dave. Thanks for your replies :)

    I finally found out the issue, when I log in the user, I pass the member i found(with the created data only) and not the member with the updated data.

    It was a mistake I made in the login flow. (Sorry for the confusion)

    But looking into the logs started helping me finding the issue, so again thanks for the help! (Learned about the log viewer)

Please Sign in or register to post replies

Write your reply to:

Draft