Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

UserController

Return to previous page

  • 4/7/2015
  • 10078 Views

Comments

10078 Views

UserController

Last updated long time ago

Comments

Common

(Enter the content of this article below)

Advanced

 
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
Contents
No sections defined
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out