Apparently, I don't think you can sync either member group nor member. My workaround has to create customer ApplicationEventHandler to initialize default member groups.
Below is my currently solution plugged in my ApplicationEventHandler. I hope this may help.
private void InitializeMemberGroups(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
string[] groups = new[] { <your group names> };
var existGroups = applicationContext.Services.MemberGroupService.GetAll().Select(x => x.Name).ToList();
var newGroups = groups.Except(existGroups);
foreach (var newGroup in newGroups)
{
applicationContext.Services.MemberGroupService.Save(new MemberGroup { Name = newGroup });
}
}
The sample code I provided is to create member groups , I have another function running after this to initiate some default members, and assign them to the member groups created by previous sample code.
uSync Member Groups
Hi, am I missing something? How can I enable Member Group sync? It seems my coworkers get at least one, but I dont know why?
Are people using Member Types to set auth permission logic?
Thanks Sean
Hi Sean
Apparently, I don't think you can sync either member group nor member. My workaround has to create customer ApplicationEventHandler to initialize default member groups.
Below is my currently solution plugged in my ApplicationEventHandler. I hope this may help.
Thank you so much, can't get this running with latest umbraco, but hopefully I can figure it out. I get the concept. :)
Much appreciated!
Btw, my solution was a bit easier. Hopefully I'm not doing anything crazy (c# is not my main language),
It seems that adding roles that already exist is handled by the service (hopefully wont bloat database with multiple groups).
You're welcome. Glad to hear it helps.
The sample code I provided is to create member groups , I have another function running after this to initiate some default members, and assign them to the member groups created by previous sample code.
Happy coding :)
is working on a reply...