Sitefinity Rookie Guide : Get Users in a Custom Role

To get users in a custom role, make sure to use the Role manager with Default Provider in Sitefinity.

commit 5ce3ae2 · authored · 1 min read

Sitefinity Rookie Guide : Get Users in a Custom Role

I am pretty new to Sitefinity and started learning since one of the upcoming projects is need to be done in the Sitefinity.

Now spent few days in a POC, in which one requirement is to list users in a custom role that we created. And it can be achieved easily using below code,

var roleMngr = RoleManager.GetManager("Default");
var usersInCustomRole = roleMngr.GetUsersInRole("CustomRole");
foreach (var user in usersInCustomRole)
{
var userProfileManager = UserProfileManager.GetManager();
var sitefinityProfile = userProfileManager.GetUserProfile<SitefinityProfile>(user);
...
}

Replace the CustomRole with the role name which you have created, in my case, it was Reviewer. Since we want users in a custom role (i.e role which we created), we need to use the Default provider.

The custom roles you created are part of the Default Provider.

In case of built-in roles, use AppRoles as the provider name to get the role manager.

local graph · open full graph

"Sitefinity Rookie Guide : Get Users in a Custom Role" is connected to the topics Sitefinity, CMS and related to 5 other entries. Sitefinity Development - Problems and Solutions Sitefinity Development - Pr… Sitefinity - Caching issue for pages with NO CACHING profile Sitefinity - Caching issue … Sitefinity - Read localized resource labels in MVC widget Sitefinity - Read localized… Best Umbraco Packages Best Umbraco Packages Umbraco Get Current Page in Partial View Umbraco Get Current Page in… Sitefinity #sitefinity CMS #cms Sitefinity Rookie Guide : Get Use…

comments

loading discussion…