UserProfileManager.GetUserProfile returns null - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

UserProfileManager.GetUserProfile returns null

  • UserProfileManager.GetUserProfile returns null
  • In the following code, the function getUserProfile was returning null.

    private static UserProfile GetUserProfile(User user = null)

                UserProfileManager profileManager = UserProfileManager.GetManager();

                if (user == null) 
                    UserManager userManager = UserManager.GetManager();
                    user = userManager.GetUser(SecurityManager.CurrentUserId);
                SitefinityProfile profile = null;
                if (user != null) 
                    profile = profileManager.GetUserProfile<SitefinityProfile>(user);
                return profile;

    It returned null, because the user created in sitefinity did not have any data in some required fields (first name, last name, phone # - which I made as a required custom field). 

    If anyone in the future is creating front end crud for users, I hope this information helps them.