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
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With