Hey Jackie,
I was able to overcome this type of problem by using a helper class and making use the Comments field in the MembershipUser's field. For example, I may require the following information about a Member before they log in for the first time (i.e., before their profile is created):
The helper class would have items like, CreateNewMembershipUser that takes username, password, email, and also my custom field fName, lName and language. The method creates a new MembershipUser, populates the standard/required fields, and then adds my custom properties to the user. Finally, the user is updated (Membership.UpdateUser()) and then returned.
To get/set these custom properties, I have two private methods:
private static void SetCustomAttribute(ref MembershipUser user, string attributeName, string attributeValue)
and
private static string GetCustomAttribute(MembershipUser user, attributeName)
The SetCustomAttribute method is responsible for maintaining a semi-colon delimited list of name=value pairs. If I pass in "FirstName", for example, SetCustomAttribute will either add the string "FirstName=[value]" to the Comments, or replace "FirstName=[oldvalue]" with "FirstName=[newvalue]". In case you're wondering why I use the ref keyword before MembershipUser parameter, it is to remind the caller of this method that the MembershipUser provided may be altered by the method call.
The GetCustomAttribute method is responsible for parsing the attributeName=value string out of the Comments field. If it is found, the value (right side of the name=value) is returned. Else, an empty string is returned.
Using the above two private methods, I expose a number of public methods for setting/getting custom properties, providing a class that looks something like this:
static class MembershipHelper
{
public static string GetFirstName(MembershipUser user)
{
// code...
}
public static void SetFirstName(ref MembershipUser, string firstName)
{
// code...
}
public static string GetLastName(MembershipUser user)
{
// code...
}
public static void SetLastName(ref MembershipUser, string firstName)
{
// code...
}
private static void SetCustomAttribute(ref MembershipUser, string attributeName, string attributeValue)
{
// code...
}
private static string GetCustomAttribute(MembershipUser user, string attributeName)
{
// code...
}
}
It's not the most technical of solutions, like implementing your own MembershipProvider, but it has been good enough for me so far.
The only caveat to keep in mind is that you don't have full control over the capacity of the Comments field, so make sure you do testing to ensure that everything you need to keep there as a custom property can fit as a name/value pair.
Good luck!
Brian
You should look into the _ProfileProvider_ instead.
Documentation can be found here:
I'm trying to extend the current EPiServer CMS 5's user profiles to have a bit more information. I know how its done on a code level with .NET's MembershipProviders. But how do I get the Edit User/Create User pages within the /edit and /admin side of EPiServer to include these new fields in its UI?
Previously EPiServer 4.6x had things like 'company', 'first name', 'last name', etc in there - but EPiServer CMS 5 only has 'username', 'password', 'confirm password', etc. I need the extra fields like it used to be with 4.6x. I've found this page is rendering the UserMembership.ascx control file inside /admin. But I can't seem to find anywhere that explains how to extend that for the extra fields.
Thanks.