Is your feature request related to a problem? Please describe
The Users collection has no way to distinguish between admins and regular users, meaning anyone with an account has the same level of access to data and the admin panel.
Describe the solution you'd like
Add a role field to the Users collection and implement access control across the board.
1. Create src/payload/access/isAdmin.ts — a reusable helper that returns true if the logged-in user has the admin role.
2. Add a role field to src/payload/collections/Users.ts:
| Field |
Type |
Required |
Notes |
role |
select |
yes |
Options: admin / user, defaults to user. Only admins can update this field. |
3. Add collection-level access control to Users:
| Operation |
Rule |
create |
Anyone (open registration) |
read |
Admins can read all; users can only read their own profile |
update |
Admins can update all; users can only update their own profile |
delete |
Admins only |
4. Lock the admin panel — update the admin config so the panel is hidden from non-admin users.
Describe alternatives you've considered
No alternatives considered — role-based access is a standard requirement for any multi-user system with an admin panel.
Additional context
Ref: https://payloadcms.com/docs/access-control/overview
BEFORE MERGING
Is your feature request related to a problem? Please describe
The Users collection has no way to distinguish between admins and regular users, meaning anyone with an account has the same level of access to data and the admin panel.
Describe the solution you'd like
Add a
rolefield to the Users collection and implement access control across the board.1. Create
src/payload/access/isAdmin.ts— a reusable helper that returnstrueif the logged-in user has theadminrole.2. Add a
rolefield tosrc/payload/collections/Users.ts:roleadmin/user, defaults touser. Only admins can update this field.3. Add collection-level access control to Users:
createreadupdatedelete4. Lock the admin panel — update the
adminconfig so the panel is hidden from non-admin users.Describe alternatives you've considered
No alternatives considered — role-based access is a standard requirement for any multi-user system with an admin panel.
Additional context
Ref: https://payloadcms.com/docs/access-control/overview
BEFORE MERGING
pnpm typegen)