Copied to clipboard

Flag this post as spam?

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


  • Sara 4 posts 94 karma points
    May 22, 2019 @ 16:10
    Sara
    0

    Register Member snippet doesn't save any custom property in MemberProperties

    Hi,

    I'm tring to create a simple member registration form and I'm using the standard "Register Member" snippet (in Umbraco 7.14.0).

    I'm using the standard Member Type "Member", updated with some other member properties like:

    • First Name
    • Last Name
    • Company
    • etc.

    All of them have their options "Show on member profile" and "Member can edit" checked. In fact the properties are showing correctly in the registration form page. So far, so good.

    But when I fill them, and submit the form, none of the custom properties are saved in the new member just created. Only the standard properties, like Name, Email and Password are saved.

    I thought it was a bug and I've looked for a solution on the forum. I found some posts and comments reporting similar issues (like this comment), but no solution to my problem.

    This behaviour is very strange because I only used the snippet, with no other modifications. Am I missing something? Or is just a bug that has never been fixed?

    Thanks,

    Sara

  • Sara 4 posts 94 karma points
    May 28, 2019 @ 07:59
    Sara
    0

    I'm having the same problem when updating member profile infos. In the "Edit Profile" Partial View Snippet, every custom property is apparently editable with text inputs, but none of them is actually saved when the form is submitted.

    I really need to get this working :(

    Has anyone found a solution or a workaround for this issue?

    Thanks.

  • Sara 4 posts 94 karma points
    Jun 10, 2019 @ 10:52
    Sara
    100

    Ok, if anybody has encountered the same problem, here's the workaround I found for it.

    Code from the "Register Member" snippet [NOT WORKING]

        @if (registerModel.MemberProperties != null)
        {
            for (var i = 0; i < registerModel.MemberProperties.Count; i++)
                {
                    @Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name)
    
                    @Html.EditorFor(m => registerModel.MemberProperties[i].Value)
                    @Html.HiddenFor(m => registerModel.MemberProperties[i].Alias)
                    <br />
                }
        }
    

    Instead of looping through the MemberProperties array with the index i, I was able to access the properties by retrieving them one by one. I used the actual index number instead of the variable i.

    New code [WORKING]

        @if (registerModel.MemberProperties != null)
        {
            // first property
            @Html.LabelFor(m => registerModel.MemberProperties[0].Value, registerModel.MemberProperties[0].Name)
    
            @Html.EditorFor(m => registerModel.MemberProperties[0].Value)
            @Html.HiddenFor(m => registerModel.MemberProperties[0].Alias)
            <br />
    
            // second property
            @Html.LabelFor(m => registerModel.MemberProperties[1].Value, registerModel.MemberProperties[1].Name)
    
            @Html.EditorFor(m => registerModel.MemberProperties[1].Value)
            @Html.HiddenFor(m => registerModel.MemberProperties[1].Alias)
            <br />
    
            // ... and so on for all the other MemberProperties defined in my MemberType
            }
        }
    

    For some reason, the for loop was adding the prefix "CS$<>8__locals1" to all of the properties attributes. The Alias of the properties passed by the registration form didn't match the Alias of the properties defined in the MemberType.

    With this fix, the Alias match and the values of the properties are correctly saved on the new member created.

Please Sign in or register to post replies

Write your reply to:

Draft