Skip to main content

How to read DNN custom user profile properties

Dear All,
here is a function for getting DNN user profile properties (Note it's only working with DNN6.0+ versions)

//Import these two classes
using DotNetNuke.Entities.Profile;
using DotNetNuke.Entities.Users;


//Place this function
 protected string GetProfilePropertyValue(string propertyName)
        {
            string value;

            ProfilePropertyDefinition ppd = UserInfo.Profile.GetProperty(propertyName);


            if (ppd == null)
            {
                value = "";
            }
            else
            {
                value = ppd.PropertyValue;
                if (value == null)
                {
                    if (String.IsNullOrEmpty(ppd.DefaultValue))
                        value = String.Empty;
                    else
                        value = ppd.DefaultValue;
                }
            }
            return value;
        }

Regards
Rashid Bilgrami
http://www.bestvisualization.com

Comments