Copied to clipboard

Flag this post as spam?

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


  • Matt 268 posts 690 karma points
    1 week ago
    Matt
    0

    Automatically add members to group on sign up

    Hi,

    How can i automatically add members to a group on sign up? I'm using the snippet which comes with Umbraco 8

        @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @using System.Web.Mvc.Html
    @using ClientDependency.Core.Mvc
    @using Umbraco.Web
    @using Umbraco.Web.Controllers
    
    
    @{
        @*
            You can specify a custom member type alias in the constructor, the default is 'Member'
            for example, to use 'Custom Member' you'd use this syntax:
    
            var registerModel = Members.CreateRegistrationModel("Custom Member");
        *@
    
        var registerModel = Members.CreateRegistrationModel();
    
        @*
            Configurable here:
    
            registerModel.RedirectUrl       - Optional. What path to redirect to if registration is successful.
                                              By default the member will be redirected to the current umbraco page
                                              unless this is specified.
    
            registerModel.UsernameIsEmail   - the default is true
                                              if you want the username to be different from the email
                                              address, set this to true and add a new Username field in
                                              the form below
    
                                              @Html.LabelFor(m => registerModel.Username)
                                              @Html.TextBoxFor(m => registerModel.Username)
                                              @Html.ValidationMessageFor(m => registerModel.Username)
        *@
    
        Html.EnableClientValidation();
        Html.EnableUnobtrusiveJavaScript();
        Html.RequiresJs("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js");
        Html.RequiresJs("https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js");
        Html.RequiresJs("https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.11/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 succeeded.</p>
    }
    else
    {
        using (Html.BeginUmbracoForm<UmbRegisterController>("HandleRegisterMember"))
        {
            <fieldset>
                <legend>Register Member</legend>
    
                @Html.ValidationSummary("registerModel", true)
    
                @Html.LabelFor(m => registerModel.Name)
                @Html.TextBoxFor(m => registerModel.Name)
                @Html.ValidationMessageFor(m => registerModel.Name)
                <br />
    
                @Html.LabelFor(m => registerModel.Email)
                @Html.TextBoxFor(m => registerModel.Email)
                @Html.ValidationMessageFor(m => registerModel.Email)
                <br />
    
                @Html.LabelFor(m => registerModel.Password)
                @Html.PasswordFor(m => registerModel.Password)
                @Html.ValidationMessageFor(m => registerModel.Password)
                <br />
    
                @if (registerModel.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 < 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>Register</button>
            </fieldset>
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft