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
This is not so much as a question, but just something I wanted to share, since it took some work for me to figure it out.
When creating new groups programmatically, one can set the default permissions, but they are somewhat cryptic, and not that intuitive.
Here is the list of default permissions for Groups (these will give access to specific features)
User Group Permissions
Cultures and Hostnames (I) Public Access (P) Rollback (K) Browse Node (F) Create Content Template (ï) Delete (D) Create (C) Publish (U) Permissions (R) Send To Publish (H) Unpublish (Z) Update (A) Copy (O) Move (M) Sort (S)
so, in order to use these in your code, do something like this:
First create the IUserGroup
UserGroup group = new UserGroup { Alias = "mycustomgroup", Name = "My Custom Group", Icon = "icon-umb-members", Permissions = new List<string> { "I", "P", "K", "F", "ï", "D", "C", "U", "A", "O", "S" }, StartContentId = 1080, StartMediaId = 1081, Key = Guid.NewGuid() }; group.AddAllowedSection("content"); group.AddAllowedSection("media");
Then create the group in Umbraco
public UserGroup CreateUserGroup(IUserGroup group) { UserGroup newGroup = (UserGroup)userService.GetUserGroupByAlias(group.Alias); if (newGroup != null) throw new Exception("Group already exists"); try { userService.Save(newGroup); ConnectorContext.AuditService.Add(AuditType.New, -1, newGroup.Id, "User Group", $"User Group {newGroup.Name} has been created"); return newGroup; } catch (Exception ex) { logger.Error(typeof(UserGroupHelper), ex.Message); logger.Error(typeof(UserGroupHelper), ex.StackTrace); throw; } }
This is exactly what I was looking for - thanks for sharing!
For anyone who would like these as string constants, here you go!
public static class UmbracoUserGroupPermission { public static string CulturesAndHostnames => "I"; public static string PublicAccess => "P"; public static string Rollback => "K"; public static string BrowseNode => "F"; public static string CreateContentTemplate => "ï"; public static string Delete => "D"; public static string Create => "C"; public static string Publish => "U"; public static string Permissions => "R"; public static string SendToPublish => "H"; public static string Unpublish => "Z"; public static string Update => "A"; public static string Copy => "O"; public static string Move => "M"; public static string Sort => "S"; }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Default User Group Permissions
This is not so much as a question, but just something I wanted to share, since it took some work for me to figure it out.
When creating new groups programmatically, one can set the default permissions, but they are somewhat cryptic, and not that intuitive.
Here is the list of default permissions for Groups (these will give access to specific features)
User Group Permissions
so, in order to use these in your code, do something like this:
First create the IUserGroup
Then create the group in Umbraco
This is exactly what I was looking for - thanks for sharing!
For anyone who would like these as string constants, here you go!
is working on a reply...