Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
In v8 is it possible to create user groups and assign users to those groups, the way we can with members and roles using the IMemberService?
I had a look at the IUserService and can create users just fine but not groups or assignations.
Is this in another service or is it not possible?
thanks
Hi Damion
I think it is! there is an overload of the Save method of the UserService that accepts a UserGroup object, and an array of ids corresponding to Users to add...
I am gleaning this by looking at the source for the code here:
https://github.com/umbraco/Umbraco-CMS/blob/853087a75044b814df458457dc9a1f778cc89749/src/Umbraco.Core/Services/Implement/UserService.cs#L843
but I think something like this could work...
UserGroup SuperAdmins = new UserGroup() { Alias = "superAdmins", Name="Super Admin" }; userService.Save(SuperAdmins, new int[] { 123, 124 });
regards
Marc
Hi Marc,
thanks for the reply, I'll give this a go and mark as accepted as soon as
cheers
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Create user groups and assign users in code
In v8 is it possible to create user groups and assign users to those groups, the way we can with members and roles using the IMemberService?
I had a look at the IUserService and can create users just fine but not groups or assignations.
Is this in another service or is it not possible?
thanks
Hi Damion
I think it is! there is an overload of the Save method of the UserService that accepts a UserGroup object, and an array of ids corresponding to Users to add...
I am gleaning this by looking at the source for the code here:
https://github.com/umbraco/Umbraco-CMS/blob/853087a75044b814df458457dc9a1f778cc89749/src/Umbraco.Core/Services/Implement/UserService.cs#L843
but I think something like this could work...
regards
Marc
Hi Marc,
thanks for the reply, I'll give this a go and mark as accepted as soon as
cheers
is working on a reply...