Necessary classes:
com.liferay.portal.service.UserGroupRoleLocalServiceUtil com.liferay.portal.service.RoleLocalServiceUtilAdd Site-Role to user:
UserGroupRoleLocalServiceUtil. addUserGroupRoles(userId, groupId, roleIds);Get all users with a specific site-role:
ListCheck if user has regular role:userIds = new ArrayList<>(); Role role = RoleLocalServiceUtil.getRole(long companyId, String roleName); List userGroupRoles = UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole(long groupId, long roleId); for(UserGroupRole u:userGroupRoles){ userIds.add(u.getUserId()); }
RoleLocalServiceUtil.hasUserRole(long userId, long roleId);Check if user has site role:
UserGroupRoleLocalServiceUtil.hasUserGroupRole(long userId, long groupId, String roleName);