Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I've developed membership systems on Umbraco 4.x websites before, using code like this:
public partial class Register : System.Web.UI.UserControl
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
// add member to role
// set member property
Member member = Member.GetMemberFromLoginName(this.CreateUserWizard1.UserName);
if (member != null)
Property FirstNameProperty = member.getProperty("firstName");
if (FirstNameProperty != null)
TextBox FirstNameTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FirstName");
FirstNameProperty.Value = FirstNameTextBox.Text;
Property SurnameProperty = member.getProperty("surname");
if (SurnameProperty != null)
TextBox SurnameTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Surname");
SurnameProperty.Value = SurnameTextBox.Text;
Property EmailProperty = member.getProperty("email");
if (EmailProperty != null)
TextBox EmailTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email");
EmailProperty.Value = EmailTextBox.Text;
// Log user in automatically
Now I'm trying to do the same (essentially, create a member via a registration form, assign the member to a group and populate a couple of properties on the member type, such as 'firstName' and 'lastName') but on Umbraco 6.0.2.
In Umbraco 6(.0.2) it seems the umbraco membership methods like 'GetMemberFromLoginName' are obsolete. So instead I'm using the standard .NET membership provider, so I've created the member like this:
MembershipUser member = System.Web.Security.Membership.GetUser(this.CreateUserWizard1.UserName);
However, I'm not sure now how to assign the property values (firstName etc) to this member. I've Googled and I the examples I've found seem to assume more knowledge than I have. I've also read the umbraco WIKI article but I'm never quite sure if that stuff is up to date and it actually loses me around the 'creating profiles' part (is a profile just the name for a collection of Umbraco member properties, so I need to create a profile on my Umbraco member and then I can set the properties on this as they are in my Umbraco member type? Then I also need to add all of the properties from the member type to the web.config file?)
I know this stuff is probably second nature for a .NET dev, which is why it's largely assumed knowledge, but I'd really appreciate some practical pointers here to help me understand it a little more and help to populate my member with the full set of properties.
Thanks for any pointers folks!
The way we usually do this is using a ProfileBase class. See this excellent explanation by Aaron (yes, it's from 2010 but still valid :) ): http://www.aaron-powell.com/umbraco-members-profiles
With this setup, we can do things like this after creating the member:
// Save member propertiesvar profile = MemberProfile.GetUserProfile(member.UserName);profile.FirstName = firstName;profile.LastName = lastName;profile.ScreenName = username;profile.Save();
Thanks Tom. Aaron's article seems to be an extended version of the Wiki article, so it gives more background on it, which is useful. It does seem a bit odd having to delcare member properties in the web.config file, but at least I know that's the right way to do it and having tested just now, it works!
Hi you dont need to define in the web config and your code. Please see my blog post below. Might be a bit rough. Still finishing it, but should be correct. Charlie :)
In version 4 of Umbraco the membership model changed from Umbraco's to ASP.net's implementation. Something I have noticed being asked a lot on the Umbraco boards was how to access custom properties against members in code. A lot of the advice pointed towards one of two implementations. A web config implementation, which meant you have your properties defined in the web config as well as you code or a strongly typed implementation which meant no properties in the web config, but as you will see throws a error in some cases.
For this example we must assume that I have a member in Umbraco with:
User name: firstname.lastname@example.org
Custom property name: FirstName
Custom property alias: firstname
WEB CONFIG IMPLEMENTATION : This means having properties defined in your web config and your code
<!--WEB CONFIG -->
<profile defaultProvider="UmbracoMemberProfileProvider" enabled="true">
<add name="UmbracoMemberProfileProvider" type="umbraco.providers.members.UmbracoProfileProvider, umbraco.providers"/>
<add name="surname" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />
<!-- END WEB CONFIG -->
Next we simply get or set the property's from or to our profile base within a model or class.
public someclass : ProfileBase
public const FIRSTNAME = “firstname”;
//get the current user by their user name (Umbraco member)
public static someclass METHODNAME()
//pass the current user's user name as a parameter and setup a profile base
public static someclass GetProfile(string username)
public string Somemethod(some parameters)
//Assign the value to the profile base
base[“FIRSTNAME”] = property;
//Or get the value from the profile base
property = base["FIRSTNAME"];
//END OF WEB CONFIG IMPLEMENTATION
STRONGLY TYPED IMPLEMENTATION : This means not having properties defined in your web config
Another implementation attempted is strongly typed access to the member properties.
//No properties defined in the web config
<profile defaultProvider="UmbracoMemberProfileProvider" enabled="true" inherits="BSD.PCSG.Configuration.MemberProfile">
//get the current users user name
//pass the current users user name as a parameter and setup a profile base
public string firstname
base[“FIRSTNAME”] = value
value = base[“FIRSTNAME”]
Now after much frustration and a lot of help, the conclusion was that Umbraco was doing some sort of case-insensitive match on the property alias. Thus if you have a property and alias of the same name it thinks there are two values because they have both been changed to lower case. So what you have to do is insure that the alias and name of your property(s) are not identical when they are both made lower case.
In our example we will changed the alias like so:
User name: email@example.com
Custom property alias: _firstname
public const FIRSTNAME = “_firstname”;
public string _firstname
Now you should be have strongly typed access to your custom member properties and no properties needing to be defined in the web config.
Thanks for reading, please comment, suggest new topics and correct me if you think there is a better way of doing something
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted