Copied to clipboard

Flag this post as spam?

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


  • Jonathan Sedman 4 posts 24 karma points
    Aug 03, 2015 @ 13:41
    Jonathan Sedman
    0

    How to render custom member properties, Umbraco 7.

    Hi,

    I'm trying to create some custom properties for members and allow the members to edit them on the front end via a form in umbraco 7.

    I've created the properties in the back office in Members -> Member types -> Generic properties.

    Im now struggling to find out how to show the properties to the member and allow them to edit and save them.

    There seems to be a lot of very different advice from various versions of umbraco but i cant seem to find a definitive answer for umbraco 7. Could anyone tell me what the best way to accomplish this is?

    Cheers, Jonny.

  • Per Olsson 47 posts 307 karma points
    Aug 03, 2015 @ 14:42
    Per Olsson
    0

    Hi Jonathan,

    You will have to call GetCurrentMemberProfileModel to get the properties.

    Here's a snippet I've wrote before:

    var profileModel = Members.GetCurrentMemberProfileModel();
    
    ...
    
    for (var i = 0; i < profileModel.MemberProperties.Count; i++)
    {
    
        @Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.MemberProperties[i].Name)
        @* 
            By default this will render a textbox but if you want to change the editor template for this property you can 
            easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would
            create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to 
            render your specific editor template like:
            @Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor")
        *@
        @Html.TextBoxFor(m => profileModel.MemberProperties[i].Value, new { @class = "form-control"})
        @Html.HiddenFor(m => profileModel.MemberProperties[i].Alias)                
    }                   
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies