The UserController class lives in the DotNetNuke.Entities.Users namespace and is the primary way to programatically work with Users. It contains a lot of useful methods and properties, all of which are detailed in the API documentation for this (and the rest of the public API) is available with the API documentation at
API documentation.
Accessing the current user
One of the most common tasks module developers want to do is to access the details for the current user. To do so, code such as the following can be used
Dim userInfo = UserController.GetCurrentUserInfo()
This users properties can then be easily accessed e.g.
dim userid as integer=userInfo.userid
In addition lots of useful methods can be executed e.g. to check if the user is in a particular role:
Dim userInfo = UserController.GetCurrentUserInfo()
if (userInfo.IsInRole("ContentEditors")) Then
' do some contenteditors related actions here
End If
Note: if you want to work with roles at a more granular level, you will utilise the
RoleController class.
Additional references:
Create a New User and Add to Specific Role Programatically