Copied to clipboard

Flag this post as spam?

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


  • Henry 21 posts 141 karma points
    Oct 23, 2015 @ 14:27
    Henry
    0

    Updating a member email & login

    Hi,

    I've got a custom surface controller to handle membership. I've got an update member action as follows:

    [HttpPost]
        [ActionName("MvcMemberUpdate")]
        public ActionResult MvcMemberUpdateForm(MvcMemberUpdateModel model)
        {
            var memberService = Services.MemberService;
            var member = memberService.GetByEmail(model.Email);
    
            member.SetValue("firstname", model.FirstName);
            member.SetValue("lastname", model.LastName);
    
            memberService.Save(member);
    
            TempData["Success"] = true;
    
            return RedirectToCurrentUmbracoPage();
        }
    

    I also want to let the member update their email address (which I also want to be the same as their username.) What is (are) the alias of these properties?

    e.g. member.SetValue("email", model.Email);

    Can the MemberService be used to achieve what I want it to?

    Cheers, Henry

  • Birger 14 posts 34 karma points
    Nov 04, 2015 @ 10:04
    Birger
    0

    I believe it's as simple as this:

    member.Email = model.Email;
    member.Username = model.Email;
    
  • Harvey 28 posts 122 karma points
    Oct 08, 2017 @ 21:32
    Harvey
    0

    I found a slight issue with updating the currently logged in member this way.

    Generally, it does not work Umbraco Public access.

    Further, methods like Umbraco.MembershipHelper.GetCurrentMember() return null.

    I believe this is because the current member cookie has an email attached to it, but this is not updated when you update the member.

    I recommend logging out the user after they have changed their username so that they can login again.

Please Sign in or register to post replies

Write your reply to:

Draft