i am searching for a solution where it is possible to get a registration form in umbraco with a MemberType choice. I already found questions for getting membertypes of members that are already registered or questions about creating membertypes programmaticly but not something like a registration form where you are able to choose your future MemberType.
Furthermore i found some information about cmsPropertyData
and that there are the member details are stored. But isn't there an easier solution then a manual SQL Query or to create an own RegistrationModel?
All i already have is the standard registration form:
var registerModel = Members.CreateRegistrationModel();
using (Html.BeginUmbracoForm<UmbRegisterController>("HandleRegisterMember"))
{
<fieldset>
<legend>Registrierung</legend>
@Html.ValidationSummary("registerModel", true)
<div class="form-group">
@Html.LabelFor(m => registerModel.Name)
@Html.TextBoxFor(m => registerModel.Name, new { @class = "form-control" })
@Html.ValidationMessageFor(m => registerModel.Name)
</div>
<div class="form-group">
@Html.LabelFor(m => registerModel.Email)
@Html.TextBoxFor(m => registerModel.Email, new { @class = "form-control" })
@Html.ValidationMessageFor(m => registerModel.Email)
</div>
<div class="form-group">
@Html.LabelFor(m => registerModel.Password)
@Html.PasswordFor(m => registerModel.Password, new { @class = "form-control" })
@Html.ValidationMessageFor(m => registerModel.Password)
</div>
<div class="form-group">
</div>
@if (registerModel.MemberProperties != null)
{
for (var i = 0; i < registerModel.MemberProperties.Count; i++)
{
@Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name)
@*
By default this will render a textbox but if you want to change the editor template for this property you can
easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would
create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to
render your specific editor template like:
@Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor")
*@
@Html.EditorFor(m => registerModel.MemberProperties[i].Value)
@Html.HiddenFor(m => registerModel.MemberProperties[i].Alias)
<br/>
}
}
@Html.HiddenFor(m => registerModel.MemberTypeAlias)
@Html.HiddenFor(m => registerModel.RedirectUrl)
@Html.HiddenFor(m => registerModel.UsernameIsEmail)
<button class="btn btn-default">Registrieren</button>
</fieldset>
}
Maybe some changes in the MembershipHelper?
I prefer to use the umbraco integrated membership method, but if there isn't any way to do this i think there won't be an alternative.
EDIT:
I change the way to do it like the follow:
First of all i get all MemberType with
var service = ApplicationContext.Services.MemberTypeService;
var memberTypes = service.GetAll();
then i go through a foreach loop with the memberTypes
and give the Value to an Action Method:
@foreach (var memberType in memberTypes)
{
<li>
@Html.ActionLink("Als " + memberType.Alias, "RedirectToCorrectRegistrationForm", "RegistrationSurface", new { memberTypeAlias = memberType.Alias }, new { @class = "page-scroll" })
</li>
}
The SurfaceController saves the memberType in a TempData and the registration form is able to handle with a memberTypeAlias
public ActionResult RedirectToCorrectRegistrationForm(string memberTypeAlias)
{
TempData["MemberType"] = memberTypeAlias;
return RedirectToUmbracoPage(1072);
}
Register.cshtml:
var registerModel = Members.CreateRegistrationModel(TempData["MemberType"].ToString());