Copied to clipboard

Flag this post as spam?

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


  • Andrew McKay 20 posts 90 karma points
    Mar 17, 2020 @ 15:41
    Andrew McKay
    0

    Automatically add new member to Member Group on registration in Umbraco 8

    Hi all, Using Umbraco 8.5, I've created an area in my members backend where I'm going to allow selected "admin" members to register new members.

    Only catch is I need to also automatically have those new members added to the admin's own member group(s) on registration.

    I've searched through the forums and can't find any detailed instructions on how to set up the classes/models in Umbraco 8 I'd need and how to implement them (relatively new to MVC and brand new to the concept of the Umbraco Composer & Components so having a hard time wrapping my brain around it).

    I'm using the default "Register Member" snippet for the registration.

    The "out of the box" CreateRegistrationModel is great, however it only allows me to customise the newly registered members alias, not their Member Group.

    The logic I've thought of is to find the current member groups of the "admin" user when signed into the registration page using "Members.GetCurrentUserRoles();" and use that value to somehow assign it to the newly registered member.

    Any thoughts?

  • Nick Hillman 17 posts 130 karma points
    Aug 11, 2020 @ 10:33
    Nick Hillman
    0

    Hi Andrew,

    Did you manage to work this out? I have a similar issue and so far have drawn a blank.

    many thanks

    Nick

  • Andrew McKay 20 posts 90 karma points
    Aug 11, 2020 @ 10:41
    Andrew McKay
    0

    Hi there. Sadly, no. I hadn't figured a solution for this before the pandemic hit... :-/ Just back working now though and will get to look at it again. Will post again if a solution is found..

  • Matt 358 posts 841 karma points
    Aug 11, 2020 @ 10:57
    Matt
    0

    Hello,

    Not sure if this helps but I have this on Umbraco 8

    I have a controller called RegisterMemberController.cs which I beleive is just the default, then added the following at the bottom;

        private void AssignMemberGroup(MembershipUser member, string email)
        {
            try
            {
                Services.MemberService.AssignRole(member.Email, member.Email.ToLower().EndsWith("@companyname.net") ? "Approved" : "For Review");
            }
            catch (Exception ex)
            {
                ProfilingLogger.Error(GetType(), ex);
            }
    
        }
    

    How we wanted it is anyone who signed up with @companyname.net got put into an approve group, anyone who signed up without @companyname.net email would be put in the review group.

    Not quite what your after but hopefully helps in some way.

    @Nik thanks again for your help with this.

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft