Adding User to Role

Topics: Administration, General
Jan 17, 2014 at 6:27 AM
I am building a customer module and i need to add user to particular role during registration process. how can i achieve that?
Jan 17, 2014 at 7:51 AM
Edited Jan 17, 2014 at 7:51 AM
With the help of following code i am able to add member to role but dashboard link never appears on home page even i can see record has been inserted in table
name "Orchard_Roles_UserRolesPartRecord"
        private void Created(UserContext context)
        {
            var role = _roleService.GetRoleByName("Members");
            if (role != null)
            {
                _userRolesRepository.Create(
                    new UserRolesPartRecord
                    {
                        UserId = context.User.Id,
                        Role = role
                    });
            }
        }   
Jan 17, 2014 at 12:47 PM
Basically i followed the following link

http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-8

to register customer/user from website, but this user does not have access to dashboard ? i tried assign role to user during process but no luck.