Extend umbraco member with property

烈酒焚心 提交于 2020-01-24 22:23:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!