Copied to clipboard

Flag this post as spam?

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


  • Shada 55 posts 137 karma points
    Dec 03, 2015 @ 11:31
    Shada
    0

    add comments to member programmatically

    When I create members I want to fill the property "Comments" (member property on Membership tab). How can I do that?

    Creating members:

    var membershipHelper = new MembershipHelper(UmbracoContext);
                      UmbracoRegisterModel regModel = membershipHelper.CreateRegistrationModel("Member");
                      regModel.Password = Membership.GeneratePassword(
                          Membership.MinRequiredPasswordLength,
                          Membership.MinRequiredNonAlphanumericCharacters);
                      regModel.Email = model.Email;
                      regModel.Name = model.Company;
                      regModel.Username = model.Name;
                      regModel.LoginOnSuccess = true;
                      regModel.UsernameIsEmail = false;
    
                      MembershipCreateStatus status;
                      membershipHelper.RegisterMember(regModel, out status);
    
  • Per Olsson 47 posts 307 karma points
    Dec 03, 2015 @ 12:03
    Per Olsson
    100

    Have you tried the MemberService instead?

            // change the model properties
            var member = Services.MemberService.CreateMemberWithIdentity(model.Username, model.Email, model.Name, "YourMemberTypeHere");
            member.SetValue("Comments", "A comment");
            Services.MemberService.Save(member);
            memberService.SavePassword(member, model.Password);
    
Please Sign in or register to post replies

Write your reply to:

Draft