+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Access classification custom field in user profile

Access classification custom field in user profile

1 posts, 0 answered
  1. Sophie
    Sophie avatar
    5 posts
    Registered:
    09 Jun 2016
    01 Jul
    Link to this post

    Hi,

    I created a hierarchical classification and I added this as a custom field in the basic user profile. The problem is that now, I would like to get the value of selected items in this hierarchical classification on the user profile of current user.

    UserProfileManager profileManager = UserProfileManager.GetManager();
    UserManager userManager = UserManager.GetManager();
     var userId = ClaimsManager.GetCurrentIdentity().UserId;
     User user = userManager.GetUser(userId);

    if (user != null)
    {
                    SitefinityProfile profile = profileManager.GetUserProfile<SitefinityProfile>(user);            
                    var extranetObj = profile.GetValue("extranet");

                    profile.SetValue("Extranet", extranetObj);         
                    profileManager.SaveChanges();
                }
    But how to access to selected values in extranetObj (my hierarchical classification) and how to set selected value in it?

    Thanks for your help

1 posts, 0 answered