API Questions on Kentico API.
Version 6.x > API > How to Add Custom User Settings to UserInfo object View modes: 
User avatar
Member
Member
Jeff Bramwell - 10/25/2011 1:07:15 PM
   
How to Add Custom User Settings to UserInfo object
I am handling user authentication programmatically by overriding the OnAuthentication method. I have no problems creating a new instance of UserInfo and setting most of the default properties. I would like to also add a custom value to the UserInfo object - e.g. CustomerID but haven't been able to figure this out. I've tried various ways of interacting with the UserSettings property but haven't had any luck getting anything in and back out again. I can modify the UserSettingsID but I'm not sure what the original intent for this property is.

How can I add custom values to the UserInfo object and get them back out again?

--- Thanks, Jeff

User avatar
Member
Member
kentico_michal - 10/30/2011 4:53:16 AM
   
RE:How to Add Custom User Settings to UserInfo object
Hello,

The UserSettingsID field is ID of related record from CMS_UserSettings table. So, you should not override its value.

I would recommend you to add a custom field to CMS_User table using Site manager interface [Development -> System tables -> edit User table -> add a new attribute].

Then, you can access (set and get value) the new field using SetValue and TryGetValue of UserInfo class:

UserInfo.TryGetValue(string columnName, out object value)

UserInfo.SetValue(string columnName, object value)


Best regards,
Michal Legen

User avatar
Member
Member
Jeff Bramwell - 10/31/2011 10:25:32 AM
   
RE:How to Add Custom User Settings to UserInfo object
Michal,

Thanks for your reply. That was exactly what I was looking for!

--- Thanks, Jeff