Create a user profile property programmatically
using (SPSite site = new SPSite("SiteURL")
{
SPServiceContext spServiceContext = SPServiceContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(spServiceContext);
if (profileManager.Properties.GetPropertyByName("<CustomPropertyName>") == null)
{
PropertyCollection properties = profileManager.Properties;
Property property = properties.Create(false);
property.Name = "<CustomPropertyName>";
property.DisplayName = "<CustomPropertyDisplayName>";
property.Type = "string (Single Value)";
property.Length = 40;
property.IsUserEditable = true;
property.PrivacyPolicy = PrivacyPolicy.OptIn;
property.DefaultPrivacy = Privacy.Public;
property.IsVisibleOnEditor = false;
properties.Add(property);
}
}
No comments:
Post a Comment