The most common ways to query a user profiles are:
In this examples, you make a query for the specified user and pass it to the GetUserPofile<T> method of the manager.
Querying a profile by username
The code for querying a user profile by username is similar to the one for querying user profiles by user’s ID. The only difference is that you query the user by calling the GetUser(string username) overload.
Alternatively, you can make a query for all the profiles and filter them by a desired criteria. You must call the desired overload of the GetUserProfiles method. Note that it returns all available profiles no matter their type. If you have other profile implementations, you must filter the collection by the type of the profile.
Querying all profiles by role
In the code above, you get an instance of the role manager class by passing the provider name for the predefined roles that are built in Sitefinity CMS. Using the role manager you get all the users in a specific role. Next, you get an instance of the user profile manager class and get all the user profiles. Finally, you match the user ID's of the user profiles with the user ID's of the users in the specified role and return the result.
Sign up for our free beginner training. Boost your credentials through advanced courses and certification. Register for Sitefinity training and certification.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important