SPSite site = SPContext.Current.Site;
SPWeb objWeb = site.RootWeb;
objWeb.AllowUnsafeUpdates = true;
SPList list = objWeb.SiteUserInfoList;
SPField field;
if (!list.Fields.ContainsField("FieldName"))
{
field =
list.Fields.CreateNewField(SPFieldType.Text.ToString(), "FieldName");
list.Fields.Add(field);
list.Update();
}
else
{
//list.Fields.Delete("FieldName");
//list.Update();
}
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWeb web = SPContext.Current.Site.RootWeb;
//Save values to user
profile list
SPUser user = web.CurrentUser;
SPListItem userItem =
web.SiteUserInfoList.GetItemById(user.ID);
userItem["FieldName"]
= 1025;
userItem.Update();
});
//Read values from user profile list
SPUser user1 = SPContext.Current.Web.CurrentUser;
SPListItem userItem1 = SPContext.Current.Site.RootWeb.SiteUserInfoList.GetItemById(user1.ID);
string languageID = userItem1["FieldName"].ToString();