I'm trying to update the user profile in a custom module. Everything works, except in the userprofile table it creates/updates the profile properties for the null portalid (host) instead of my current portalid (0 in this case). Any ideas on why this happens or how to make it update using the propertydefintionid for the current portal?
Public Sub UpdateProfile()
Try
Dim user As New Users.UserInfo()
user.Profile.InitialiseProfile(PortalId)
user.Username = UserInfo.Username
user.UserID = UserInfo.UserID
user.Profile.FirstName = UserInfo.FirstName
user.Profile.LastName = UserInfo.LastName
user.Membership.Email = UserInfo.Email
If Trim(txtStreet.Text) <> "" Then
user.Profile.Street = txtStreet.Text
End If
If Trim(txtUnit.Text) <> "" Then
user.Profile.Unit = txtUnit.Text
End If
If Trim(txtCity.Text) <> "" Then
user.Profile.City = txtCity.Text
End If
If ddlState.SelectedValue <> "" Then
user.Profile.Region = ddlState.SelectedValue
End If
If ddlCountry.SelectedValue <> "" Then
user.Profile.Country = ddlCountry.SelectedValue
End If
If Trim(txtZip.Text) <> "" Then
user.Profile.PostalCode = txtZip.Text
End If
If Trim(txtPhone.Text) <> "" Then
user.Profile.Telephone = txtPhone.Text
End If
Users.UserController.UpdateUser(PortalId, user)
Catch ex As Exception
lblDebug.Text += "<br>Update Profile:" & ex.Message.ToString
End Try
End Sub