Contour forms and Umbraco members 25
Contour 1.1.9 has just been shipped. It’s a minor release, but it adds a nifty little feature making it super easy to work with member data. Default values and workflow settings bracket syntax has now been updated to support member values.
Member values as default field values
Say that you have a comment form on your website with the standard fields (name, email, website and comment).
In the case when an Umbraco member is currently logged in and you want to pre-populate the name and email fields with the values from the logged in member, it’s now just a matter of setting the default value using the bracket syntax.
You can access: member.id, member.loginname, member.email and for custom properties simply use the alias member.customalias.
Full details on the syntax can be found in the Contour developer documentation.
Member values in workflow settings
Of course it’s also possible to use this syntax in workflow settings. For example, sending an email to the current member when a form has been submitted, just set the email setting to {member.email}
Member profile editor
Combine the default values with a workflow that will update the member details and you have a member profile editor.
Let’s start with a simple member type with just a single property with the alias custom.
I want the members to be able to edit their email and the value for the custom property so I’ll create a form with 2 fields (email address and custom property).
The default value of the email field has been set to {member.email}
And the one for custom property has been set to {member.custom}
So now if I request the form when I’m logged in as an Umbraco member, the fields should be populated with the current member values.
The next step is to make sure the member values get updated when the form is submitted. This can be done with a workflow (workflow is part of the contour strikes again project).
The workflow simply maps the member type properties to the contour form fields. When the form is submitted the member properties will be updated. Once this is in place you have a working profile editor.
Make sure you have at least Contour version 1.1.9 in order to use these features. Install and upgrade instructions can be found on the contour project page.