retrieving custom profile fields - General Discussions - General Discussions - Progress Community
 General Discussions

retrieving custom profile fields

  • retrieving custom profile fields
  • Hi all,
    First, I am not a programmer and am learning as I go, so I apologize if this is a very simple matter. I was wondering if someone could point me in the right direction.

    I know I can programmaticly pull for instances the current user's name using:
    var UserID = Telerik.Sitefinity.Security.SecurityManager.GetCurrentUserName();
    lblInfo.Text = UserID;

    Using the new custom field ability with 4.1, I added a field in my profile called "memberID" which is an assigned number for our members. How can I retrieve that similar to the example above to display it to a logged in user?

    Thank you in advance for any insight or suggestions.
  • Hello Amanda,

    Here is a sample code that gets the value of a custom field

               UserManager manager = UserManager.GetManager();
               User user = manager.GetUser("test");

               var pm1 = UserProfileManager.GetManager();
               var p1 = pm1.GetUserProfile(user.Id, typeof(SitefinityProfile).FullName);
               var value1 = p1.GetValue("CustomFieldName");

    Kind regards,
    Ivan Dimitrov
    the Telerik team

  • Thank you very much Ivan!  Could you tell me the namespace I need to reference for UserManager?

    Thanks again
  • Hi,

    This doesn't work for me. 

    'Telerik.Sitefinity.Security.Model.UserProfile' does not contain a definition for 'GetValue' and no extension method 'GetValue' accepting a first argument of type 'Telerik.Sitefinity.Security.Model.UserProfile' could be found (are you missing a using directive or an assembly reference?) 

    I've checked the version of my Telerik.Sitefinity.dll and it is 4.1.1339.0

    Any ideas?



  • I figured it out;

          UserManager userManager = UserManager.GetManager();
          User user = userManager.GetUser(HttpContext.Current.User.Identity.Name);
          UserProfileManager userProfileManager = UserProfileManager.GetManager();
          UserProfile profile = userProfileManager.GetUserProfile(user.Id, typeof(SitefinityProfile).FullName);
          var v = Telerik.Sitefinity.Model.DataExtensions.GetValue(profile, "School");
          //var v = profile.GetValue("School");
    And for custom profiles;
          UserProfile owsProfile = userProfileManager.GetUserProfile(user.Id, "Telerik.Sitefinity.Security.Model.owscustomerprofile");       var w = Telerik.Sitefinity.Model.DataExtensions.GetValue(owsProfile, "School");


  • Hello j8,

    You can add reference to "Telerik.Sitefinity.Model.DataExtensions". GetValue is an extension method.

    Ivan Dimitrov
    the Telerik team

  • Hi Ivan,

    Yeah I saw that mentioned before. By "adding reference to" you mean a ?

    using Telerik.Sitefinity.Model.DataExtensions;

    This gives me a

    Error 1 A using namespace directive can only be applied to namespaces; 'Telerik.Sitefinity.Model.DataExtensions' is a type not a namespace 

    Or is "adding a reference to" something other than a using clause?

  • Peter, I got it to work through a combination of things:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity.Security;
    using Telerik.Sitefinity.Security.Model;
    namespace SitefinityWebApp.UserControls.LoginInfo
        public partial class ProfileInfo : System.Web.UI.UserControl
            protected void Page_Load(object sender, EventArgs e)
                UserManager manager = UserManager.GetManager();
                User user = manager.GetUser(HttpContext.Current.User.Identity.Name);
                var pm1 = UserProfileManager.GetManager();
                var p1 = pm1.GetUserProfile(user.Id, typeof(SitefinityProfile).FullName);
                var value1 = Telerik.Sitefinity.Model.DataExtensions.GetValue(p1, "memberID");
                lblInfo.Text = value1 as string;
  • Duh!

    for anyone interested;

    This did the job;

    using Telerik.Sitefinity.Model;

    You can then use;

    UserProfile profile = userProfileManager.GetUserProfile(sitefinityUser.Id, typeof(SitefinityProfile).FullName);
    schoolName = profile.GetValue("School").ToString();



  • Is it possible to access (get and put) custom field using RestAPI?