Copied to clipboard

Flag this post as spam?

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

  • Tom Bruce 122 posts 506 karma points
    Feb 06, 2018 @ 09:01
    Tom Bruce

    How to Create Register Member Page

    Hi folks, does anyone know the Umbraco TV link for creating a register page.

    I can’t seem to find it, I was watching the videos last month, but now I can’t seem to find them!

  • Alex Brown 129 posts 618 karma points
    Feb 06, 2018 @ 09:09
    Alex Brown

    This module goes through members and logging in, is this what you mean?

  • Claushingebjerg 890 posts 2429 karma points
    Feb 06, 2018 @ 09:52

    Hi Tom

    Theres actually a built in partial snippet to do this :)

    enter image description here

  • Tom Bruce 122 posts 506 karma points
    Feb 06, 2018 @ 09:58
    Tom Bruce

    Hi Claushingebjerg,

    The built in one has a bug, the core server side validation for member email address will not accept higher case within the email.

  • Anthony Powell 12 posts 46 karma points
    1 week ago
    Anthony Powell

    For simplicity's sake I'm just going to say. Yes you can use the existing snippet.

    But if you need to attach more work flow into it. You'll need to peak that the existing code in Umbraco's "UmbRegisterController"

    Here is the code they are using internally. Modify to suit...

        public ActionResult HandleRegisterMember([Bind(Prefix = "registerModel")]RegisterModel model)
            if (ModelState.IsValid == false)
                return CurrentUmbracoPage();
            // U4-10762 Server error with "Register Member" snippet (Cannot save member with empty name)
            // If name field is empty, add the email address instead
            if (string.IsNullOrEmpty(model.Name) && string.IsNullOrEmpty(model.Email) == false)
                model.Name = model.Email;
            MembershipCreateStatus status;
            var member = Members.RegisterMember(model, out status, model.LoginOnSuccess);
            switch (status)
                case MembershipCreateStatus.Success:
                    TempData["FormSuccess"] = true;
                    //if there is a specified path to redirect to then use it
                    if (model.RedirectUrl.IsNullOrWhiteSpace() == false)
                        return Redirect(model.RedirectUrl);
                    //redirect to current page by default
                    return RedirectToCurrentUmbracoPage();
                case MembershipCreateStatus.InvalidUserName:
                    ModelState.AddModelError((model.UsernameIsEmail || model.Username == null)
                        ? "registerModel.Email"
                        : "registerModel.Username",
                        "Username is not valid");
                case MembershipCreateStatus.InvalidPassword:
                    ModelState.AddModelError("registerModel.Password", "The password is not strong enough");
                case MembershipCreateStatus.InvalidQuestion:
                case MembershipCreateStatus.InvalidAnswer:
                    // TODO: Support q/a
                    throw new NotImplementedException(status.ToString());
                case MembershipCreateStatus.InvalidEmail:
                    ModelState.AddModelError("registerModel.Email", "Email is invalid");
                case MembershipCreateStatus.DuplicateUserName:
                    ModelState.AddModelError((model.UsernameIsEmail || model.Username == null)
                        ? "registerModel.Email"
                        : "registerModel.Username",
                        "A member with this username already exists.");
                case MembershipCreateStatus.DuplicateEmail:
                    ModelState.AddModelError("registerModel.Email", "A member with this e-mail address already exists");
                case MembershipCreateStatus.UserRejected:
                case MembershipCreateStatus.InvalidProviderUserKey:
                case MembershipCreateStatus.DuplicateProviderUserKey:
                case MembershipCreateStatus.ProviderError:
                    //don't add a field level error, just model level
                    ModelState.AddModelError("registerModel", "An error occurred creating the member: " + status);
                    throw new ArgumentOutOfRangeException();
            return CurrentUmbracoPage();

    Note you can create a new model like this.

    var regModel = RegisterModel.CreateModel();
                regModel.Email = model.Email;
                regModel.Name = $"{model.Name} {model.Surname}";
                regModel.Password = model.Password;
                regModel.Username = model.Email;
                regModel.UsernameIsEmail = false;
                regModel.LoginOnSuccess = false;
Please Sign in or register to post replies

Write your reply to: