问题
I am developing web site on umbraco and need to store additional information about member(cmsMember). How can I do that? Is there a way to extend umbraco member without changing membership provider?
I would like to do something similar to this
var datatype = new DataTypeDefinition("varchar");
var type = new PropertyType(datatype);
var property = new Property(type);
property.Value = myAdditionalInfo;
member.Properties.Add(property);
memberService.Save(member, false);
Code above right now throws exception with Value cannot be null
message.
回答1:
Adding properties to a Member type can (and should) be done in the backoffice:
And then setting/saving the values should be something like this (using MemberService), though I'm not exactly sure if it's current :-s :
// Get the member
var member = Member.GetCurrentMember();
// Check if there is a current member
if (member != null)
{
// Update member properties
member.getProperty("myPropertyAlias").Value = myAdditionalInfo;
// Save the updated member
member.Save();
}
来源:https://stackoverflow.com/questions/41998177/extend-umbraco-member-with-property