Organization scoping
Give each organization its own folders in a multi-tenant app by adding access rules and an organization field with customizeFolderCollection.
In a multi-tenant app where each organization's content is separate, use customizeFolderCollection to add organization-based access control to the folders collection. The callback receives the folders collection after the plugin has added pathSegment and sortOrder, and returns the collection to use.
import { pageTreePlugin } from '@delmaredigital/payload-page-tree'
import { orgScopedAccess, createOrganizationField } from './access/organization'
pageTreePlugin({
collections: ['pages'],
customizeFolderCollection: (collection) => ({
...collection,
access: orgScopedAccess,
fields: [...collection.fields, createOrganizationField()],
}),
})orgScopedAccess and createOrganizationField stand for your own access rules and organization field; the plugin doesn't ship them.
With access rules like these in place:
- The tree view shows only the folders of the user's active organization.
- New folders are assigned to the user's organization.
- Users can only see and manage their own organization's folders.
This works because the tree loads folders with your read access applied, and every tree write runs as the requesting user. See Access control. Scope your page collections the same way.
Existing folders need a data migration
If you add organization scoping to an app that already has folders, migrate the existing folders to assign each one to an organization. Folders without an organization become inaccessible.

