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

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 a companion discussion topic for the original entry at https://our.umbraco.com/forum/97511-default-user-group-permissions

Still finding this helpful, but one was missing from this list. Here’s the final list of the letters and the meanings from the v14 Migration that removed them.

RIP cryptic letters! :joy:

2 Likes

A shame something like this has zero documentation. Just stumbled across this post trying to solve a similar issue.

Coincidently, we came across this today!

Beware that ActionRights.ActionLetter (“Umb.Document.Permissions”) is currently not in use and commented out in the UI code. I think this is because in Umbraco 13 you can set the permissions via a menu action on the node itself and that is absent in Umbraco 17.