Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Test View modes: 
User avatar
Certified Developer v6
Certified Developer v6
hoppe - 12/18/2012 10:25:34 AM
   
Test
I'm creating a new user using the Kentico API.
var user = new UserInfo
{
Email = email,
FirstName = fName,
LastName = lName,
Enabled = true,
IsEditor = false,
IsGlobalAdministrator = false,
UserURLReferrer = CMSContext.CurrentUser.URLReferrer,
UserCampaign = CMSContext.Campaign
};

user.LoadDefaultData();
user.UserSettings.LoadDefaultData();

I thought that the last two lines would load the CMS Site Manager defaults for the user. I.e., I have an integer field named 'UserNotificationContentFreq' that has a default value of 2, in the user setttings system table. But even in debug mode, after these calls are made, the field 'UserNotificationContentFreq' is null.

I've also saved the new user to the database, and verified there as well.

Is there a way to do this using the API? I do not want to have set the default values for all of these fields again.

version 6.0.4402

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/19/2012 1:37:50 AM
   
RE:Test
Hi,

Have you tried using this method: CMS.FormEngine.FormHelper.LoadDefaultValues(string class name, System.Data.DataRow) ?

The default field settings are in the form definition for given class - in this case cms.user.

Best regards,
Juraj Ondrus

User avatar
Certified Developer v6
Certified Developer v6
hoppe - 12/20/2012 4:12:04 PM
   
RE:Test
I didn't realize that the UserInfo object was a datarow. Making these two calls worked for me. Thanks
FormHelper.LoadDefaultValues("cms.user", user);
FormHelper.LoadDefaultValues("cms.usersettings", user);