Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Barlow | jacker.io 164 posts 740 karma points c-trib
    Sep 05, 2011 @ 17:39
    Matt Barlow | jacker.io
    1

    Adding fields to the membership profile.

    Hi,

    A quick guide to extending the default profile fields using nForum:

    Installation:

    1. Install nForum as per standard instructions.
    2. In the Umbraco admin go to members > member types and click on Forum user.
    3. Click on the generic properties tab, then add a new property. I'm adding a property to check if the user wants to signup to a newsletter, in this we are calling it "forumUserNewsletter" of type true/false.

    Sourcecode:
    Now go to nforum on codeplex : http://nforum.codeplex.com/ and download the sourcecode.

    4. Download and unzip the solution into a new folder, you will need Visualstudio 2010 to edit.
    5. Open the solution.
    6. Right click on the nForum project > Choose properties >  Build Events.
    7. Now edit the post-build command-line (click the Edit button)
    8. Change the XCOPY statements to copy into your umbraco installation folder (change the right hand-side paths to the correct ones)

    Now we're ready to edit the sourcecode, if you look there is already an example of what you need to do, "forumUserTwitterUrl" is an extension of the profile, so you just need to add your own property where this one appears throughout the code.


    9. Edit Register form - go to nForum > usercontrols > nForum > membership > Register.ascx

    <dt><label for="<%= cbNewsletter.ClientID %>">Register for Newsletter?</label></dt> 
    <dd><asp:CheckBox ID="cbNewsletter" runat="server" /></dd>

     

    11. Then in the code-behind edit the BtnSubmitClick (important,the getproperty value should be the same as property set in step 3).

     m.getProperty("forumUserNewsletter").Value = cbNewsletter.Checked ? "1" : "0" ;

    12. Edit ForumMemberProfileEdit.ascx add

    <dt><label for="<%= cbNewsletter.ClientID %>">Receive Newsletter?</label></dt>
    <dd><asp:CheckBox ID="cbNewsletter" runat="server" /></dd>

    then in the code behind add to the loadProfile method:

    if (CurrentMember.MemberAllowPrivateMessages)
    cbAllowPrivateMessages.Checked = true;

    and to the btnSubmitClick method:

    cMem.getProperty("forumUserNewsletter").Value = cbNewsletter.Checked ? "1" : "0";


    13. Edit the help class for NfMember - Go to nforum.BusinessLogic > Membershiphelper.cs adding:

     public bool MemberIsNewsletter { get; set; } to the property list.

    and the following

    MemberIsNewsletter = memberProps["forumUserNewsletter"] == "1";

    to the NfMember method.

    14. Build the solution and the files will be automatically copied into your umbraco solution (if you have set XCOPY correctly).

    15. Repeat this for each additional profile property you wish to add.

    Matt

     

  • Matt Barlow | jacker.io 164 posts 740 karma points c-trib
    Sep 05, 2011 @ 18:22
    Matt Barlow | jacker.io
    0

    Slight typo.. Step 12 should be: (add to the loadprofile method)

    if (CurrentMember.MemberIsNewsletter)
    cbNewsletter.Checked = true;
  • Lee 1130 posts 3088 karma points
    Sep 10, 2011 @ 09:29
    Lee
    0

    Nice write up :)

Please Sign in or register to post replies

Write your reply to:

Draft