Copied to clipboard

Flag this post as spam?

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


  • Echilon 29 posts 49 karma points
    Oct 28, 2013 @ 14:23
    Echilon
    0

    Adding a Property to Existing Member

    I have a bunch of members in a group, to which I'm trying to add/set a custom property. I've added the property definition in the backend but can't set the property (no exception but the change doesn't stick). What's the best way to go about this?

    This is what I have:

    var member = Member.GetCurrentMember();
    var hasAcceptedTerms = member.getProperty("HasAcceptedTerms");
    bool hasAccepted;
    if (hasAcceptedTerms == null || !Boolean.TryParse(Convert.ToString(hasAcceptedTerms.Value), out hasAccepted) || !hasAccepted) {
        member.SetProperty("HasAcceptedTerms", true);
        member.XmlGenerate(new XmlDocument());
    }
    member.Save();
    Response.Redirect("~/Forum/",true);
  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Oct 28, 2013 @ 20:43
    Andy Butland
    0

    Try instead of:

    member.SetProperty("HasAcceptedTerms",true);

    This:

    member.getProperty("HasAcceptedTerms").Value = true;

    I don't think you'll need the member.XmlGenerate() either - though not 100% on that.

    Hope that helps

    Andy

  • Echilon 29 posts 49 karma points
    Oct 29, 2013 @ 09:52
    Echilon
    0

    The problem is the property doesn't exist as it's an existing member (created before the property was added to the MemberType).

  • John 12 posts 51 karma points
    Nov 05, 2013 @ 13:36
    John
    0

    Hi Echilon

    It's been a week so I guess you might have resolved this problem but if not what I'm about to write might help you.I spent about 2 hours this morning with the same issue as you reported. I had added a property to a Member Type but the new property didn't appear as a Property under Members, it only appeared when I created a new Member using that Member Type. I found this post manually-selecting-member-properties and using the SQL query (chopping it down a bit to understand the joins and get the data I wanted) it became clear that the Member account I was using was not created with the Member Type I had added the new property to. Doh!

    I'm using umbraco 6.1.3 and on the Member Property page it doesn't show the Member Type the account was created with, it is relatively easy to query the database to get this information but I really think this would be a helpful field to see in the Member Property page (not sure how to put an 'enhancement request' in for this but I will work that out and do so when I have a bit more time).

    Hope this helps and if you still have the problem and need some help with the SQL query let me know.

    Regards,
    John

Please Sign in or register to post replies

Write your reply to:

Draft