Legacy Knowledge Base
Published Jun. 30, 2025

How to show only certain file types to a group of users?

Written By

Tímea Bihari

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • I want to show only certain file types to some users.
  • For example: they should see .doc and .pdf only but not .xls
  • Is it possible to hide/show documents based on extensions?

Environment

  • Liferay DXP 7.4

Resolution

While it is not possible to hide or show documents based on their extensions, there are a couple of ways to achieve this requirement.

Using the role-based permission system

  • Liferay DXP has a role-based permissions system. Administrators can let users collaborate on files by assigning the appropriate file permissions to a Role, and then assigning users to that Role. Consider the following steps:
  1. Navigate to Control Panel > Users > Roles
  2. Create a new Regular Role (for example "PDF access")
  3. Go to Define Permissions and add View permissions to Documents and Media
  4. Assign this role to a user who is also a Site Member
  5. Navigate to Content & Data > Documents and Media
  6. Create a new folder (eg: "PDFs")
  7. Upload the required files in this folder
  8. Edit the Permissions of the Folder
  9. Remove all Permissions for Guests and Site Members
  10. Add view permission for the role "PDF access" only
  • To verify the results:
  1. Place a Documents & Media widget on the Home Page
  2. Sign in with a user who has the "PDF access" role and see that you have access to "PDFs" folder
  3. Sign in with any other user and the folder will not appear
  •  The permissions can be added/revoked for individual files only, but if you use a separate folder you will not have to edit the permissions for each file.

Using Content Page Personalization

  • Create Experiences based on User Segments which will dynamically control what users can see.
  1. Navigate to Control Panel > Configuration > Custom Fields.
  2. Select the User entity and create a custom field of type drop-down.
  3. Name it "File Type" and provide 2 options for it:
    pdf
    doc
  4. Open the Permissions for the custom field and add View permission to User role.
  5. Create userA, where you set this field to "pdf".
  6. Create userB, where you set this field to "doc".
  7. Add both users to the Liferay site.
  8. Navigate to Site Administration for Liferay DXP > Categorization > Categories.
  9. Create a Vocabulary with the same name as the custom field: "File Type" (make sure that it is exactly the same).
  10. Add 2 categories to it, with the names corresponding to the 2 custom field values respectively: pdf and doc.
  11. Navigate to Content & Data > Documents and Media
  12. Upload 2 documents, one with each category.
  13. Navigate to People > Segments
  14. Create 2 segments (pdf segment, doc segment), a segment for each user: drag'n'drop the "File Type" property and one has to be equal with pdf and other with doc.
  15. Under Site Builder > Collections create a new Dynamic Collection and click on the blue Add Personalized Variation button.
  16. Add the 2 created segments and position them above Anyone, so they will be prioritized.
  17. Set the item types to Documents and Media/Basic Document and under filter, pdf should contain pdf category etc.
  18. Add an Asset Publisher widget to the home page, and configure it to show the created collection.
  19. Edit the home page and click on the Experience menu in the upper left corner.
  20. Create 2 new experiences: "pdf experience" with Audience set to "pdf segment", and "doc experience" with Audience set to "doc segment".
  21. Login with the userA and userB and check the results.
  • One caveat of this approach is that you have to use the categories every time you upload a document. Another way to implement this experience personalization of documents could be to create separate Document Types for the different file types and use those when you upload documents (instead of the Basic Document type). That way, you would not have to manually add categories when uploading the document, just have to make sure that you select the right document type when uploading a file.

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base