I want to automatically assign a specific user group and modules to a new user. I was able to successfully assign the user group with DefaultUserGroups property, but I can't find how to assign the modules. Does anyone know how I can do this?


1 Answer 1


By creating a User Sign-In script you can automatically assign modules when a user logs in

The below code is a rough attempt to automatically add the modules, this was just something to prove the concept.

var user = Context.User;
await user.LoadMembersAsync(null, new RelationLoadOption("ModuleToUser")).ConfigureAwait(false);
List<long> groups = new List<long>();
groups.Add(10464); // M.AssetType.Product
groups.Add(10460); // M.AssetType.Media
groups.Add(10463); // M.AssetType.Print
// update the user
await MClient.Entities.SaveAsync(user).ConfigureAwait(false);

This user sign-in automatically assigns the modules to the user. This code was to test out the concept and confirm we could update the modules.

Follow the blog for more details - https://timmarsh.co.uk/2023/02/17/sitecore-content-hub-assigning-modules-to-a-user-programmatically-on-sign-in/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.