Site information, including the date it was created and the number of members
How To articles are not official guidelines or officially
supporteddocumentation. They are community-contributed content and may
not alwaysreflect the latest updates to Liferay DXP. We welcome your
feedback toimprove How to articles!
While we make every effort to ensure this Knowledge Base is accurate,
itmay not always reflect the most recent updates or official
guidelines.We appreciate your understanding and encourage you to reach
out with anyfeedback or concerns.
Legacy Article
You are viewing an article from our legacy
"FastTrack"publication program, made available for
informational purposes. Articlesin this program were published without a
requirement for independentediting or verification and are provided
"as is" withoutguarantee.
Before using any information from this article, independently verify
itssuitability for your situation and project.
Issue
- The requirement is to get a list of all the site's names, as well as their creation dates and members. If there is a shortcut from the Liferay control panel?
Resolution
- There is currently no OOTB functionality to achieve this.
-
However, below is the groovy script that can be used to get these details:
-
import com.liferay.portal.kernel.service.GroupLocalServiceUtil;
import com.liferay.portal.kernel.service.LayoutSetLocalServiceUtil;
import com.liferay.portal.kernel.service.UserLocalServiceUtil;
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.model.LayoutSet;
import com.liferay.portal.kernel.model.User;
import java.util.Date;
//populate a list with all the sites
List < Group > groups = GroupLocalServiceUtil.getGroups(-1, -1);
for (group in groups) {
//fetch the groupId
long groupId = group.getGroupId();
//we need to use the LayoutSet's create date to find out when the site was created as there's no create date for groups
LayoutSet sitePublicLayoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, false);
Date siteCreationDate = sitePublicLayoutSet.getCreateDate();
//get the name of the site
String name = group.getGroupKey();
//get the users that belong to the site
List < User > groupUsers = UserLocalServiceUtil.getGroupUsers(groupId);
//we only need those sites to which users are added (although the creator user will always be added) and when the group is really a site.
if (groupUsers.size() > 0) {
if (group.isSite()) {
out.println("This site is called " + name + " and was created on: " + siteCreationDate + "\n");
out.println("users added to this site can be found below:")
}
for (groupUser in groupUsers) {
String screenName = groupUser.getScreenName();
out.println(screenName);
}
out.println("______________________________________________________________________________________________________" + "\n");
}
}

Did this article resolve your issue ?