Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Umbraco Get Users by User Type

Tags:

umbraco

If I have a list of user types (both ID and name), how can I get the users that belong to that user type (not members)? There doesn't seem to be any methods for User[] userList = User.Get ByType

like image 556
Atom Avatar asked Feb 24 '26 02:02

Atom


1 Answers

Using linq you should be able to get what you're looking for. Here's an example of how to get Users based solely on the alias of the User Type:

string[] userTypeAliases = new string[] { "writer", "editor" };

var userTypes = umbraco.BusinessLogic.UserType.GetAllUserTypes()
    .Where(ut => userTypeAliases.Contains(ut.Alias));

var users = umbraco.BusinessLogic.User.getAll()
    .Where(u => userTypes.Contains(u.UserType));
like image 183
Douglas Ludlow Avatar answered Feb 27 '26 01:02

Douglas Ludlow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!