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);
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.
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:
Try instead of:
This:
I don't think you'll need the member.XmlGenerate() either - though not 100% on that.
Hope that helps
Andy
The problem is the property doesn't exist as it's an existing member (created before the property was added to the MemberType).
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
is working on a reply...