November Happy Hour will be moved to Thursday December 5th.

Extend the UserData collection

Vote:
 
I need to extend the set of information that can be registered on a user in episerver. I suppose there is an easy way to add extra user-fields that can be used from, say a customized user registration page, or similar. I want to use the registered (extra) values to control display of information in my pages, and would prefer to extend the UserData collection in EPiServer if possible. Have anyone of you done this, or similar? Any input appreciated.
#12387
Oct 06, 2005 15:08
Vote:
 
See the PersonalizedData class in the SDK. It allows storing extra data for a user. if(PersonalizedData.Current!=null) { // Print current value if(PersonalizedData.Current["MyTestKey"]!=null) Response.Write(PersonalizedData.Current["MyTestKey"]); // Set new value PersonalizedData.Current["MyTestKey"] = "MyTestValue"; } Also see the post in http://www.episerver.com/devforum/ShowTopic.aspx?id=5309 on how to create a plug-in that allows an administrator to change these values for a given user.
#14174
Oct 06, 2005 17:17
Vote:
 
Ah, small detail, you need to do a Save() after setting the values. :-) /Steve
#14175
Oct 07, 2005 9:41
Vote:
 
I'm trying the same using the following code; if(_userData != null) { if (_userData["Personal" + propertyNames[_idx]] != null) { _userData["Personal" + propertyNames[_idx]] = propertyValues[_idx]; } else { EPiServer.Core.PropertyString _property = new PropertyString(); _property.Name = "Personal" + propertyNames[_idx]; _property.Value = propertyValues[_idx]; _personalizedProps.Add(_property); } } _user.Save(); if(_userData != null) _userData.Save(); I can set the std properties in PersonalizedData this way, but new fields are never saved to the DB. Or at least not retrieveable when looping over the GetProperties() collection. Any trix required? Thomas
#14176
Feb 02, 2006 22:24
Vote:
 
EPiServer will handle all values starting with "Personal", but will only save those that are "known" personal values (like name, emails etc.) So, just don't prefix with "Personal", and it should work as expected. /Steve
#14177
Feb 05, 2006 22:05
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.