This will show you how to perform various User management using the Umbraco service layer.
Learn how to use the User Service to manage the users on your Umbraco project.
To assign a User to a User Group, we need both the IUserService
and IUserGroupService
. As with all Umbraco services, these are obtained using dependency injection.
Start by defining an interface for our implementation:
Next we implement the interface. This implementation holds the dependency to the Umbraco services:
Register the implementation in a Composer:
Lastly, we need to put our implementation to use. This could be done in a Management API controller: