In Orchard CMS, users are a content type like any other. Therefore, they can be created through code in much the same way as other content types, with a few caveats.

Firstly, you create users by implementing the IUser interface and the IMembershipService, whereas other content you would create with IContentManager. Secondly, users have a UserPart attached to them, where the username and email are stored. Users also have a UserRolesPart, where an indeterminate number of roles are specified.

Although there are some really cool user activities that you can leverage in workflows, the project I'm working on really warranted getting deep into the Orchard API. I wanted to accomplish it all through code.

The Controller

As usual, this is a web API endpoint. It is triggered by an Angular application in the front end.