UserProfileManager.GetUserProfile returns null

Posted by Community Admin on 04-Aug-2018 18:43

UserProfileManager.GetUserProfile returns null

All Replies

Posted by Community Admin on 22-Nov-2015 00:00

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.

This thread is closed