Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: RE: Doubts when try yo obtaint the members of a group.
Hi,
I want to obtain the members of a site, but I am not finding the way to do it. I thinks it has to be an easy thing, but I am not able to do it. Anyone can help me? I would like to get the same users than the ones that are showed in the members tab of control panel
Thanks in advance
Regards
I'd start with userLocalService.getGroupUsers(long groupId);
As a proof of concept, run this script from Server Administration > Script and make sure it gives you the count that you see in the Site Members UI (substitue your site's groupId):
// ### Groovy Sample ###
number = com.liferay.portal.kernel.service.UserLocalServiceUtil.getGroupUsersCount(20123);
Hi,
Thanks in advance. That answer is not working because there is users which are in the site because they belong to an user group which is assigned to the site.
This is the solution that is working for me, for anyone who can need it
public static List<User> getUsersOfSite(long groupId, long companyId){
LinkedHashMap<String, Object> userParams = new LinkedHashMap();
userParams.put("inherit", Boolean.TRUE);
userParams.put("usersGroups", groupId);
long count= UserLocalServiceUtil.searchCount(companyId, null,WorkflowConstants.STATUS_APPROVED,
userParams);
List<User> users = UserLocalServiceUtil.search(companyId, null ,WorkflowConstants.STATUS_APPROVED,
userParams, 0, (int) count, (OrderByComparator) null);
List<User> returnList = new ArrayList<User>();
return returnList;
}
Thanks again for the help
Regards,
Well it doesn't sound like I was much help but I'm glad you got it sorted. What you did looks like what I see in the Site Memebership code, so nice work.
Powered by Liferay™