Copied to clipboard

Flag this post as spam?

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


  • Peter Alcock 113 posts 176 karma points
    Apr 20, 2016 @ 07:40
    Peter Alcock
    0

    Custom Member Field Upon Registration

    Hey everyone again! I have working member resgistration page below but i want to add another textbox field to form for 'Company' which the vale gets added to the members custom field alias 'client'

    I can't quite fathon how to achieve this using my below code?

     @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    
    @using System.Web.Mvc.Html
    @using ClientDependency.Core.Mvc
    @using Umbraco.Web
    @using Umbraco.Web.Controllers
    @using BlueprintUMEx.Web.Models
    @using BlueprintUMEx.Web.Controllers
    @using BlueprintUMEx.Web.Security.Extensions
    
    @{
    
    
        var registerExtendedModel = Members.CreateExtendedRegistrationModel("Member", "client");
    
    
    
        Html.EnableClientValidation();
        Html.EnableUnobtrusiveJavaScript();
        Html.RequiresJs("/umbraco_client/ui/jquery.js");
        Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");
        Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");
    
        var success = TempData["FormSuccess"] != null;
    }
    
    @*NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed*@
    @Html.RenderJsHere()
    
    @if (success) 
    { 
        @* This message will show if RedirectOnSucces is set to false (default) *@
        <p>Registration succeeeded.</p>
    }
    else
    {
        using (Html.BeginUmbracoForm<UmbExtendedRegisterController>("HandleExtendedRegisterMember"))
        {
    
            <fieldset>
                <legend>Register Member</legend>
    
                @Html.ValidationSummary("registerModel", true)
    
                @Html.LabelFor(m => registerExtendedModel.Name)
                @Html.TextBoxFor(m => registerExtendedModel.Name)
                @Html.ValidationMessageFor(m => registerExtendedModel.Name)
    
    
                     @*@Html.LabelFor(m => registerExtendedModel.Username)
                     @Html.TextBoxFor(m => registerExtendedModel.Username)
                     @Html.ValidationMessageFor(m => registerExtendedModel.Username*@
                <br />
                @Html.LabelFor(m => registerExtendedModel.Email)
                @Html.TextBoxFor(m => registerExtendedModel.Email)
                @Html.ValidationMessageFor(m => registerExtendedModel.Email)
                <br />
    
                @Html.LabelFor(m => registerExtendedModel.Password)
                @Html.PasswordFor(m => registerExtendedModel.Password)
                @Html.ValidationMessageFor(m => registerExtendedModel.Password)
                <br />
    
    
    
                @if (registerExtendedModel.MemberProperties != null)
                {
                    @*
                        It will only displays properties marked as "Member can edit" on the "Info" tab of the Member Type.
                    *@
                    for (var i = 0; i < registerExtendedModel.MemberProperties.Count; i++)
                    {
                        @Html.LabelFor(m => registerExtendedModel.MemberProperties[i].Value, registerExtendedModel.MemberProperties[i].Name)
    
                        @Html.EditorFor(m => registerExtendedModel.MemberProperties[i].Value)
                        @Html.HiddenFor(m => registerExtendedModel.MemberProperties[i].Alias)
                        <br />
                    }
                }
    
                @Html.HiddenFor(m => registerExtendedModel.MemberTypeAlias)
                @Html.HiddenFor(m => registerExtendedModel.MemberGroupAlias) @* We now need to supply the group parameter *@
                @Html.HiddenFor(m => registerExtendedModel.RedirectUrl)
                @Html.HiddenFor(m => registerExtendedModel.UsernameIsEmail)
    
                <button>Register</button>
            </fieldset>
        }
    }
    
  • Phil Veloso 38 posts 251 karma points
    Apr 14, 2020 @ 14:43
    Phil Veloso
    0

    Hiya,

    Have you tried marking the field as "Member can edit" on the "Info" tab of the Member Type? ( commented note in code snippet )

    Otherwise, if you want do this programmatically, the video below should point you in the right direction.

    https://umbraco.tv/videos/umbraco-v7/developer/fundamentals/member-api/populating-property-values/

Please Sign in or register to post replies

Write your reply to:

Draft