DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Getting UserInfo object

 4 Replies
 0 Subscribed to this topic
 26 Subscribed to this forum
Sort:
Author
Messages
New Around Here
Posts: 10
New Around Here

Hi,

I am trying to get the userId (of the UserInfo object) of the user selected by the admin user in the Manage --> Users --> (Choose a user) -> View Profile page

Using SecurityContext.getCurrentUser() or UserController.Instance.GetCurrentUserInfo() gets me the userInfo object of the currently logged on user as it should (which is the admin user in this case). But I need the userInfo object of the selected user.

Note: I am using DNN 9.4.4

Thanks in advance.

Veteran Member
Posts: 1182
Veteran Member
MVP
MVP
You're an MVP!

Mohan,

This should work for you:

DotNetNuke.Entities.Users.UserController.GetUserByName(string username)

or

DotNetNuke.Entities.Users.UserController.GetUserByName(int portalId, string username)

Happy DNNing!
Michael

Michael Tobisch
DNN★MVP

DNN Connect
New Around Here
Posts: 10
New Around Here

Hi Micheal,

Thanks for the reply. The problem I have is how do I get the username to pass as the argument. Because I dont want the UserInfo of the currently logged on user. I need the UserInfo of the user selected from the Users list in Manage --> Users

Veteran Member
Posts: 1182
Veteran Member
MVP
MVP
You're an MVP!

Mohan,

you have to know something about the user, either the user name (see example above, you find this in the first column of the grid in the second line) or the userid (eg when you click on the profile link, you see it in the querystring).

If you know the userid, you can get the UserInfo object by

DotNetNuke.Entities.Users.UserController.GetUserById(int portalId, int userId)

Happy DNNing!
Michael

Michael Tobisch
DNN★MVP

DNN Connect
New Around Here
Posts: 10
New Around Here
Hi Michael,
Thanks for the reply. I was hoping there would be a way to get the selected username without using the query string but I'll try with the querystring for now. Thanks.

These Forums are for the discussion of the open source CMS DNN platform and ecosystem.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
  2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
  3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  5. No Flaming or Trolling.
  6. No Profanity, Racism, or Prejudice.
  7. Site Moderators have the final word on approving / removing a thread or post or comment.
  8. English language posting only, please.

Would you like to help us?

Awesome! Simply post in the forums using the link below and we'll get you started.

Get Involved