Hi. How can we help?

Setup a document area for logged-in users

Last updated: 21 November 2022

Use case

  • Registered users can only upload documents to a specific category, but must not be allowed to see any other documents or categories.
  • Administrators can see and manage all the documents from the front-end.

Solution

While configuring the category permissions you can set the documents view action group selector so that only document owners can see their owned documents. This makes it easy to setup a list of documents per user for various use cases and workflows.

Create category

  1. Navigate to DOCman > Categories.
  2. Click New.
  3. Set Title to My Documents.
  4. Under Permissions click on the override button and set Categories View so that only Registered user groups can view the category. Then click on the override button and set Document View to Owner so that users can only see their own documents. Additionally, and if you'd like registered users to be able to upload their own documents themselves, you must also set the Upload documents action to Registered so that they are able to add documents in this category.

  1. Click Save.

Create a page for users

  1. From the admin area navigate to Pages > Add new.
  2. Set Title to Documents.
  3. Add DOCman Hierarchical List block.
  4. Set Category to the My Documents category.

  1. Click on Publish.

NOTE: The same result can be achieved by using shortcodes instead of the Gutenberg editor. Please follow the shortcode guide to properly configure the block to achieve the same result as above.

Create documents

There are two possible flows when creating documents:

  1. By a registered user: the document is automatically assigned to the specific user, the user cannot change this themselves. This assignment is automatically made when the user uploads the document by their self. This requires granting documents Upload permissions to the registered user group as mentioned above.
  2. By an administrator: the administrator needs to change the ownership of the document to a specific user to make it appear in their documents area. Administrators can do this while adding a new document or while editing an existing one. Document ownership can be modified in the document form by simply changing the user on the Owner selector.

Learn more about owner permissions.

Result

  • Registered users: see the My Documents page which lists only their own documents in in the My Documents category.
  • Administrators: see the My Documents menu item which lists all the documents in the My Documents category.

More

Prevent document creation

Users can add documents on the front-end if they have documents Upload permissions set. These permissions can be set globally or per category.

To prevent users from adding documents in this workflow, you need to ensure that documents Upload permissions are properly set to avoid registered users from being allowed to upload documents. By default only Administrators, editors and autors are allowed to upload new documents.

Category per user

You can also create a category for each user, if you want your users to be able to view their own category and its contents.

  1. Start by creating a Documents page and adding a Hierarchical List block, or a Flat List block (we'll use a Hierarchical List block in this example but the choice is yours).

  1. On the page block settings, select the category that will be containing the user categories (in this examplewe will be creating categories inside a category named Users documents, once again the choice is yours). If you are adding user categories at a root level then you may leave the category selector empty.
  2. Create the user documents category while properly setting the corresponding parent category (in our case that would be Users documents). Under the permission tab set the following view settings for both documents and categories:
  • Groups: Admins only
    No group members other than admins should be able to view documents in this category, or be able to view this category and any of its subcategories.
  • Users: John Doe
    John Doe should be the only user that is permitted to view documents in this category, or be able to view this category and any of its subcategories.

This will ensure that only Joe and Administrators can access the category and the documents inside.