is this the correct access to allow guest posts?
access: {
read: ({ req }) => {
if (req.user) return true
return {
_status: {
equals: 'published',
},
}
},
create: () => true,
delete: isAdmin,
update: isAdmin,
},by adding
create: () => true,? I want everyone to be able to submit posts but mark them as draft, I have also enabled
versions: {
drafts: true,
},I think that would suite your use case, you may need to set the status with a beforeChange (operation === 'create') hook, checking to see if there is a user or not and then setting the status accordingly
thanks, without using beforeChange, the status is already draft
should I use beforeChange as a security measure?
to make sure no post gets published?
If you pass a query param of
draft=falseI believe it will skip creating the draft
did you give this a shot?
not yet, but I will let you know if I stumble across an issue, thanks
Star
Discord
online
Get dedicated engineering support directly from the Payload team.