I’m trying to create a WFFM form in Sitecore to edit the current user’s profile, which is stored in the Session (different from the Sitecore.Context.User.Profile). To this end, I’m looking for a way to preload the form’s fields with the profile data from the Session.
Can this be done? I’m using Sitecore CMS 6.5 and WFFM 2.3.
It seems that the solution to the problem was a little more involved. First of all, I moved all profile information from the session to
Sitecore.Context.User‘sProfile. To do this, a custom user profile class had to be implemented. Using this approach, I know needed to preload the form fields from this custom profile instead of the session.To do this, I created a folder under the content tree, called “Profile Variables”, which represented the custom profile properties that needed to be read, in dot notation. For example:
{ DisplayName: "Home Telephone", Value: "ContactDetails.HomeTelephone" }.Finally, I created a custom WFFM field type, based on the Single Line Text field type, which takes one more property,
PreloadField, taking values from the “Profile Variables” node, and on the custom field type’sOnInitI read from the context user’s profile using reflection the value of the property stored inPreloadFieldand set the text field’sTextproperty to that value.Hope this helps somebody else in search for something similar.