We have made a test where we made a copy of the UserMemberShip.ascx file that handles the presentation of creating/changing users. We also "dumped" the code from the EPiServer dll with reflector.
In our own version of UserMemberShip.cs we made it inherit EPiServer.UI.Edit.UserMembership (if it doesn't admin mode won't work), changed the virtual void OnLoad to ovverride OnLoad, removed all protected variabels. We also added presentation/saving of in our testcase firstname at the appropriate place.
Then in web.config you only need to create a virtualpathmappings for "~/EPiServer/UI/Edit/UserMemberShip.ascx" and point it to your implementation.
Works great.
Br
Per N /Logica
Hi Per
This is an interesting article, Could we get some clarity on how to add new fields to use and where we can see the new fields being added? should they reflect in table aspnet_Users in the episerver database? e.g using
<profile enabled="true" defaultProvider="SqlProfile" automaticSaveEnabled="true">
<properties>
<add name="Address" type="System.String"/>
I'd assume saving data is not possible until the fields are created first OR is the EPiServer implementaiton different to what I'm thinking?
On that front are the editor users and say custom users all handled in the same manner? in the case of the latter part of creating own users the users will be stored with the editors/administrators and I should manage them by groups?
Hi steven
We didn't add new field we just displayed field that already existed int the default sqlProfile. I haven't tested to add new fields. It you wan't I can email you a zip with our modified files. There are comment where we have added these new fields.
Then you will have something to work with.
/Per
Hi Per,
I'd appreciate it if you could email your sample code to me please.
will.scott@ultimedia.co.uk
Thanks
I came across the same problem and thought the same way as Per. But then I started researching it a bit and EPiServer CMS 5 has a PluginArea called PlugInArea.SidSettingsArea. This wil show up as an extra tab in the "Edit User" and "Create User" templates.
Here is an example:
Markup:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UserCustomSettings.ascx.cs" Inherits="AssemblyName.Plugins.UserCustomSettings" %>
<asp:Label runat="server" Text="CrmId:" AssociatedControlID="CrmId" />
<asp:TextBox ID="CrmId" runat="server" />
Code:
[GuiPlugIn(DisplayName = "User Settings", Description = "Additional settings for the user", Area = PlugInArea.SidSettingsArea, Url = "~/Plugins/UserCustomSettings.ascx")]
public partial class UserCustomSettings : UserControl, IUserSettings, ICustomPlugInLoader
{
public PlugInDescriptor[] List()
{
return new[] { PlugInDescriptor.Load(typeof(UserCustomSettings)) };
}
public void LoadSettings(string userName, EPiServerProfile data)
{
if (!IsPostBack)
{
TextBoxCrmId.Text = data.GetPropertyValue("CrmId").ToString();
}
}
public bool SaveRequiresUIReload { get; set; }
public void SaveSettings(string userName, EPiServerProfile data)
{
data.SetPropertyValue("CrmId", TextBoxCrmId.Text);
data.Save();
}
}
Web.Config:
<add name="CrmId" type="System.String" provider="SqlProfile" />
This way you can easily add new settings to a user, but you can also display all the other fields that already exists(Address, City, Company, Title etc.).
The information will not be displayed on the "User Information" tab, but it is much easier then making your own UserMemberShip.ascx file and create VirtualPathMappings for it. It it also more robust against future upgrades.
Hope this helps!
Br, Tore
Hi,
I have a problem with displaying EPiServerProfile user data in a gridview. First i created a gridview and displayed my collection of EPiServerProfile which consisted of UserName, FirstName and Lastname. And that went well, but if i try to add new properties in episerverprofile my gridview can't recognise the newly created fields.
For example i want to store the name of the role in a episerverprofile property like a string, cause i find it more convinient to find the name of the role that way. So i've added the following to web.config under <profile>
<add name="UserRole" type="System.String"/>
After that i create new users so the property will recieve a value. But i recieve this error message: A field or property with the name "UserRole" was not found in the selected datasource.
And its just working with the predefined properties which shows up in Intellisense, like FirstName, LastName, Email, etc. for example ZipCode which is'nt in Intellisense is not working.
Do i need to instantiate the newly added properties somewhere? Or do i need some workaround so they'll show up in Intellisense for the gridview to recognize the fields?
Ideas?
BR Johannes