Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Programmatically update custom profile property valuesProgrammatically update custom profile property values
Previous
 
Next
New Post
11/28/2013 12:59 PM
 
Hi,

I need to be able to create a new user and set the value of a custom profile property. Please see my code below which creates the new user, sets the value of a default property (Biography) and also sets the value of my custom property (CRMContactID), however, the custom property value doesn't save. I have tried both UserController.UpdateUser() and ProfileController.UpdateUserProfile() to do the update but neither seem to work for me.

Any help would be very much appreciated. Thanks.

Dim objUserInfo As New UserInfo
With objUserInfo
.DisplayName = myFirstName & " " & myLastName
.Email = myEmailAddress
.FirstName = myFirstName
.LastName = myLastName
.Username = myEmailAddress
.IsSuperUser = False
.PortalID = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().PortalId

.Membership = New UserMembership(objUserInfo)
.Membership.Password = myPassword
.Membership.Approved = isApproved
.Membership.UpdatePassword = passwordUpdateRequired
End With

Dim objCreateStatus As DotNetNuke.Security.Membership.UserCreateStatus = UserController.CreateUser(objUserInfo)

If objCreateStatus = DotNetNuke.Security.Membership.UserCreateStatus.Success Then
With objUserInfo
.Profile.Biography = "still testing"
.Profile.SetProfileProperty("BMFAContactID", myBMFAContactID)
End With
UserController.UpdateUser(DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().PortalId, objUserInfo)

'DotNetNuke.Entities.Profile.ProfileController.UpdateUserProfile(objUserInfo)

 
New Post
11/29/2013 3:43 AM
 
Sorry, the custom property name is BMFAContactID and not CRMContactID like I said above. And sorry for the H1 formatting on the last line, don't know what happened there!
 
New Post
3/4/2014 8:21 AM
 
When adding a new user, you must -first- update the user itself. Then, afterwards, alter their custom profile field(s) and finally call ProfileController.UpdateUserProfile.

You'll also want to call UserInfo.Profile.InitialiseProfile on objUserInfo, prior to setting it's profile properties, to have the profile initialized for the new user.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Programmatically update custom profile property valuesProgrammatically update custom profile property values


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out