UserController

Return to previous page

  • 4/7/2015
  • 4171 Views

Comments

4171 Views

UserController

Last updated 6 years 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

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out