开发者

dnn - Added Profile information to a new userinfo Object (as part of custom registration)

Currently I have a fully working Register form. However I now need add the users Address on to the form, everything is fine untill I come to add the users address information

Dim newUser As New UserInfo
//Memebership and Userinfo added
newUser.Profile.PreferredLocale = Services.Localization.LocaleController.Instance.GetCurrentLocale(Me.PortalId).Code
newUser.Profile.SetProfileProperty("PostalCode", "S62 6EP")
newUser.Profile.City = txtCity.text
newUser.Profile.Country = txtCountry.text
newUser.Profile.Region = txtRegion.text
newUser.Profile.Street = txtstreet.text
newUser.Profile.Unit = unit.text

The Reason for Postalcode been differnet was a test to see if it changed the outcome (it didnt)

Basically the user is regisetered fine. However when I go to the UserProfile page the data is not there. only the firstname and lastname are in the fields.

It seems to add the data to the db under the wrong propertydefinitionID (example p开发者_开发问答referedlocale adds with an ID of 19, but if I change it in the UserProfile page I get 38


Here is how I create new users.


DotNetNuke.Entities.Users.UserInfo uInfo = new UserInfo();
uInfo.Username = txtEmail.Text.ToString();
uInfo.Membership.Password = txtPassWord.Text.ToString();
uInfo.PortalID = 0;//this should be appropriate portal id if you want to support multi portal registrations
uInfo.Email = txtEmail.Text.ToString();
DotNetNuke.Security.Membership.UserCreateStatus status = DotNetNuke.Entities.Users.UserController.CreateUser(ref uInfo);
if (status == DotNetNuke.Security.Membership.UserCreateStatus.Success)
{
     //TODO User Created Successfully - update your profile properties here

}
else
{
   //TODO Error Creating user s
   //something like lblError.Text = status.ToString();
}

So hint for you is to set proper portal id for user and do save the profile properties by calling appropriate function once you are done with setting properties.

I hope this will help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜