DNN Forums

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

Database query - user's data of currently logged in user

 4 Replies
 1 Subscribed to this topic
 37 Subscribed to this forum
Sort:
Author
Messages
New Around Here
Posts: 5
New Around Here

Hello Community,

currently I am trying to program a specialised bookmark website for users of our DNN website. I would like to ask the community the following question: is there any possibility to determine the user's data (user's ID, first name, last name, etc....) of the currently logged in user from the database ? So to speak, is there a way to find out the currently logged in user's data by using an SQL query against the database ? If yes, which tables are involved in the query against the database?  Thank you in advance.

Veteran Member
Posts: 1246
Veteran Member
MVP
MVP
You're an MVP!
Probaqbly not with a simple SQL query. There are methods that can be called from code, as in a module.
New Around Here
Posts: 5
New Around Here

Thanks for the hint, how can I access these methods ? Do you have some sort of sample code ?

Veteran Member
Posts: 1246
Veteran Member
MVP
MVP
You're an MVP!
Have a look at the DNN API Documentation at https://dnndocs.com/api/

You probably should look at the namespaces whose names begin with DotNetNuke.Entities.Users.

As for coding, do you have any experience with DNN Module Development? What is your level of understanding of the internals of DNN? You'll probably want to get some sort of handle on that before starting off.

As for coding, you might get a head start with some scripts using the Razor module or install 2sxc for a much more powerful tool that also supports Razor. That will save you a bit in learning about module development, but to be replaced by learning how to use these tools. Check the Community Blog and also 2sxc.com for more information.

And, ask questions ...

For module development, Mitchel Sellers' book "Professional DotNetNuke Module Programming" is still available and relevant. Also, Professional DNN7: Open Source .NET CMS Platform.

Both of these books, though not current, will give you a lot of the basics.

Also, here is a nice series of blog posts on module development: https://www.dnnsoftware.c...s--blog-series-intro

As for code samples, you might want to get source code for various module from the DNN project itself for from https://github.com/DNNCommunity.

If i was starting out, I'd start with a simple 2sxc template that returns a list of users. You can then get a single user by userid, or by searching by some field. From there, you can get all of the data about a particular user. You can bypass much of this by getting the details of the current logged-in user.

To start with a simple module, Chris Hammond's templates are popular. Installed on a local machine, you can create a simple module, and work your way through by debugging it and looking at data returned by various calls.

And keep asking questions ...

New Around Here
Posts: 5
New Around Here
Dear Joe Craig, thank you very much for your useful hints and links - I will keep asking questions :-)

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