Copied to clipboard

Flag this post as spam?

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


  • MBE 244 posts 845 karma points
    Mar 26, 2019 @ 19:33
    MBE
    0

    Disable created member by default

    Hi guys,

    Is it possible to manually approve members? They shouldn't be approved automatically upon registering.

    Cheers!

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Mar 26, 2019 @ 23:51
    Alex Skrypnyk
    0

    Hi,

    Yes this is possible, just create members that are not approved, just create a member with IsApproved = false value, like that:

                            var member = Services.MemberService.CreateMember(customer.Email.Trim(),
                                customer.Email.Trim(),
                                customer.Name, "Member");
    
                            member.IsApproved = false;
                            Services.MemberService.Save(member);
    

    Thanks,

    Alex

  • MBE 244 posts 845 karma points
    Mar 28, 2019 @ 12:25
    MBE
    0

    Hi Alex!

    I'm not that experienced with using Umbraco's API to modify the memberships (or anything in that regard).

    When you kindly share the above example. How exactly do you implement it? Do you create a class in the App_Data folder and apply it there?

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Mar 29, 2019 @ 10:02
    Alex Skrypnyk
    0

    It's better if you show how do you create a member? Can you show the code?

  • MBE 244 posts 845 karma points
    Mar 29, 2019 @ 21:04
    MBE
    0

    It's just the snippet I use, I haven't figured out how to do otherwise :)

        @{
    
        var registerModel = Members.CreateRegistrationModel();
        registerModel.UsernameIsEmail = false;
    
        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;
    }
    <section id="loginregister" class="sectionMargin">
        <h1 class="section-headline"><span>Opret medlemsskab</span></h1>
        <div class="container">
            <div class="col-md-6">
                @Html.RenderJsHere()
    
                @if (success)
                {
                    @CurrentPage.GetPropertyValue("successBesked")
                }
                else
                {
                    using (Html.BeginUmbracoForm<UmbRegisterController>("HandleRegisterMember"))
                    {
    
                        @Html.ValidationSummary("registerModel", true)
    
                        <div class="floating-label">
                            @Html.TextBoxFor(m => registerModel.Username)
                            @Html.LabelFor(m => registerModel.Username)
                            <div class="icon">
                                <i class="fa fa-user"></i>
                            </div>
                            @Html.ValidationMessageFor(m => registerModel.Username)
                        </div>
    
                        <div class="floating-label">
                            @Html.TextBoxFor(m => registerModel.Name)
                            @Html.LabelFor(m => registerModel.Name)
                            <div class="icon">
                                <i class="fa fa-user"></i>
                            </div>
                            @Html.ValidationMessageFor(m => registerModel.Name)
                        </div>
    
                        <div class="floating-label">
                            @Html.TextBoxFor(m => registerModel.Email)
                            @Html.LabelFor(m => registerModel.Email)
                            <div class="icon">
                                <i class="fa fa-envelope"></i>
                            </div>
                            @Html.ValidationMessageFor(m => registerModel.Email)
                        </div>
    
                        <div class="floating-label">
                            @Html.PasswordFor(m => registerModel.Password)
                            @Html.LabelFor(m => registerModel.Password)
                            <div class="icon">
                                <i class="fa fa-lock"></i>
                            </div>
                            @Html.ValidationMessageFor(m => registerModel.Password)
                        </div>
    
                        @Html.HiddenFor(m => registerModel.MemberTypeAlias)
                        @Html.HiddenFor(m => registerModel.RedirectUrl)
                        @Html.HiddenFor(m => registerModel.UsernameIsEmail)
    
    
                        <button class="userbtn">Register</button>
    
                    }
                }
            </div>
            <div class="col-md-6">
                @Umbraco.Field("bodyText")
            </div>
        </div>
    </section>
    
  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Mar 30, 2019 @ 00:30
    Alex Skrypnyk
    0

    I think we need a code of "UmbRegisterController"

    There should be a logic that saves members and set approved or not.

    Thanks,

    Alex

  • MBE 244 posts 845 karma points
    Mar 30, 2019 @ 11:29
    MBE
    0

    My apologies Alex, but I have no idéa where to find it. I tried searching my entire solution for "IsApproved" and "Save(member)" but it yields no results.

    I haven't changed anything regarding creating users. I simply included that snippet and what kind of magic it doesn, I don't know.

    The UmbRegisterController you are talking about, all it has inside is this, which is meta data.

    public class UmbRegisterController : SurfaceController
    {
        public UmbRegisterController();
    
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult HandleRegisterMember([Bind(Prefix = "registerModel")] RegisterModel model);
    }
    
  • AddWeb Solution Pvt. Ltd 89 posts 329 karma points
    Mar 27, 2019 @ 06:46
    AddWeb Solution Pvt. Ltd
    0

    You can always fork and tweak or you could do some backoffice tweaking and just hide the options with some js/css logic...

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies