is it possible to possible to give only edit access on particular page
Hi! Yes, with access functions, you can either return a boolean or an query constraint
https://payloadcms.com/docs/access-control/collections#updateThe query constraint can be used to limit which document(s) a user can read/edit
@dr_mint but it's for collection ri8?
i want to apply at page level
The query constraint allows you to filter which pages you want to give access. If you want to give access to a single page based on its ID, you may use the following query
{ id: { equals: "idToGiveAccessTo" } }
thanks @dr_mint i'll try
hello @dr_mint i tried but i got id as undefined
i have to use hook or accessControl?
i'm getting confuse
i want to allow only career page access to the user those have a 'hr' role
import type { Access } from 'payload/config';
import { checkRole } from './checkRole';
const adminAndHrAndUser: Access = ({ req: { user }, id }) => {
if (user) {
if (checkRole(['admin'], user)) {
return true;
}
if (checkRole(['hr'], user)) {
if (id === '64df354b4574c2098e2c196a') {
return true;
}
return {
id: user.id,
};
}
return {
id: user.id,
};
}
return false;
};
export default adminAndHrAndUser;
this is my code
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.