Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to read custom Profile Property?How to read custom Profile Property?
Previous
 
Next
New Post
4/18/2009 6:31 PM
 

Greetings.

I'm having problems for reading a custom Profile Property from module source code.
I created the property (Users - Profile Properties - added as a Text with length 10).
I can WRITE the property (because I see value in database, table userprofile), but cannot READ it.

 Code (commented lines were unsuccessful attempts):

DotNetNuke.Entities.Users.UserInfo ui = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
//string credits = ui.Profile.GetPropertyValue("Credits");
//string credits = ui.Profile.ProfileProperties.GetByName("Credits").PropertyValue;
//foreach (DotNetNuke.Entities.Profile.ProfilePropertyDefinition def2 in ui.Profile.ProfileProperties)
//    credits += "<BR>" + def2.PropertyName;
if (string.IsNullOrEmpty(credits))
{
 credits = new Random().Next().ToString();
 DotNetNuke.Entities.Profile.ProfilePropertyDefinition def = DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionByName(0, "Credits");
 ui.Profile.ProfileProperties.Add(def);
 ui.Profile.SetProfileProperty("Credits", credits);
 DotNetNuke.Entities.Profile.ProfileController.UpdateUserProfile(ui, ui.Profile.ProfileProperties);
}
return credits;
 

Can anyone help me?

Thank you,
Ricardo

 
New Post
4/22/2009 10:43 PM
 

Nobody? I can't believe that nobody did it before. I can't believe that it's so difficult either, but I cant find how to do it.

Thanks

 
New Post
8/10/2009 7:02 PM
 

 

Has anyone figured this out?  I have found many posts from people asking how to read user defined profile properties, but no answers.

Other than reading from the database, is it possible to read user-defined profile properties in DNN 5?

Many, many thanks to anyone who can solve...

 

 
New Post
8/11/2009 12:09 AM
 

The following works for me for the current user and also returns the default value for the custom profile property if the field has not been populated with data:

Function GetProfilePropertyValue(ByVal propertyName As String) As String
   Dim value As String
   Dim ppd As ProfilePropertyDefinition = UserInfo.Profile.GetProperty(propertyName)
   If ppd Is Nothing Then
      value = ""
   Else
      value = ppd.PropertyValue
      If value Is Nothing Then
           If String.IsNullOrEmpty(ppd.DefaultValue) Then
                value = String.Empty
           Else
                value = ppd.DefaultValue
           End If
      End If
  End If
  Return value
End Function

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
8/12/2009 12:45 PM
 

Thanks Bill - it works perfectly.  Here's the c-sharp version of Bill's code in case others want it...

        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;
        }
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to read custom Profile Property?How to read custom Profile Property?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out