MonoX Custom user fields 

Viewed 28563 time(s), 3 post(s), 12/24/2010 3:25:34 PM - by MarthaB
12/24/2010 3:25:39 PM
46 Reputation 8 Total posts

Hello,
I need custom attributes for my portal users which are not present in the default installation: for example, city, gender, custom avatar, etc. This means that I have to have those fields on the registration screen and also on the profile parts. How to achieve this?

This content has not been rated yet. 
1
2/11/2011 3:40:08 PM
60 Reputation 5 Total posts

I'll try to describe the easiest way of doing this in few (relatively) short steps:

1. In the root folder of the MonoX CMS create your project specific folder (in the most cases we name it by the name of the project)
2. As we will be working with the Membership Web part we will need to create a sub folder called WebParts (to distignuish ordinary UserControls from WebParts )
3. Copy the "MembershipEditor.ascx" WebPart from the "\Portal\MonoX\ModuleGallery\Membership\MembershipEditor.ascx" to your Web parts folder
4. Create your codebehind file that will hold all your custom code etc. (don't forget to change the "Inherits" property inside the mark-up of "MembershipEditor.ascx")
5. In the mark-up file you can add your own controls (city, etc.) e.g.

<asp:PlaceHolder ID="plhNewsletter" runat="server">
<dd style="margin: 0px; padding: 0px;">
<label> </label>
<asp:CheckBox ID="chNewsletter" runat="server" />
<label style="width: 60%; margin: 0px; padding: 0px; display: inline; text-align: left;" for="<%= chNewsletter.ClientID %>"><%= Resources.DefaultResources.Registration_Label_NewsletterSubscription %></label>
</dd>
</asp:PlaceHolder>
<asp:PlaceHolder ID="plhRememberMe" runat="server">
<dd style="margin: 0px; padding: 0px;">
<label> </label>
<asp:CheckBox ID="chkRememberMe" runat="server" />
<label style="width: 60%; margin: 0px; padding: 0px; display: inline; text-align: left;" for="<%= chkRememberMe.ClientID %>"><%= Resources.DefaultResources.MembershipEditor_RememberMe%></label>
</dd>
</asp:PlaceHolder>


6. Now you need to state that your class inherits from "MonoSoftware.MonoX.ModuleGallery.MembershipEditor" e.g. "public partial class MembershipEditor : MonoSoftware.MonoX.ModuleGallery.MembershipEditor"

7. To execute your custom code you need to attach to some of the exposed events:

AccountCreating
AccountCreated
AccountCreationCompleted
AccountUpdating
AccountUpdated
AccountUpdateCompleted

To read more about this event please download MonoX API reference from http://www.mono-software.com/Downloads/#MonoX .

e.g.

void MembershipEditor_AccountCreated(object sender, MembershipModuleEventArgs e)
{
   AddUserToRole(e);
   PostAccountCreationActions(new Guid(e.MembershipUser.ProviderUserKey.ToString()));
   SendNotifications(e);
   AddUserProfile(new Guid(e.MembershipUser.ProviderUserKey.ToString()));
}

8. we recommend that you store all custom data in your own (separate) DB table

If you have any questions or you need clarification on how to do any of the described actions do not hesitate to contact us.

Rated 5.00, 1 vote(s). 
2
12/24/2010 3:39:01 PM
46 Reputation 8 Total posts

Thanks, that was what I was looking for.

This content has not been rated yet. 
3
This is a demo site for MonoX. Please visit Mono Software for more info.