More in this section
Forums / Developing with Sitefinity / UserProfileManager.GetUserProfile returns null

UserProfileManager.GetUserProfile returns null

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Jeremy
    Jeremy avatar
    10 posts
    Registered:
    13 May 2015
    22 Nov 2015
    Link to this post

    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.

1 posts, 0 answered