API
Version 7.x > API > getting author information in app code View modes: 
User avatar
Member
Member
yogasukma - 12/4/2013 2:44:42 AM
   
getting author information in app code
hi guys,

i want to make notifier to user author when document update using custom event handler (full post here http://devnet.kentico.com/Forums/f65/fp5/t40917/notify-author-when-his-post-updated.aspx)

now i am success to send email when document updated, bot now the problem is i can't get author of document.

i use CMS.CMSHelper.CMSContext.CurrentUser.UserName but it give me username of user active, i want to get the email of author document so i can send email to him.

anyone have idea?

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 12/21/2013 1:56:51 PM
   
RE:getting author information in app code
Hello,

When you navigate to the given document in your CMSDesk / Content section and go to Properties / General tab, author is stored in -> "Created by" property? "Created by" property you could find as DocumentCreatedByUserID column in the CMS_Document table. So, you can get it also using the SQL query... then by ID of respective user, as you can find them in CMS_User table.

Or can also follow the Dev Guide API examples: Managing Documents where you can get the document node, and then via the NodeOwner property get the document owner ID (Created By)... and all the users info and appropriate user IDs are stored in the database table CMS_User.

simple example of getting author ID of the "Home" document:
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/Home", "en-us");

string authorID = node.NodeOwner;

Best regards,
Martin Danko