Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Collection access to allow guest posts

default discord avatar
generator1013 years ago
4

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,
    },
  • discord user avatar
    jarrod_not_jared
    3 years ago
    @944284724824801302

    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

  • default discord avatar
    generator1013 years ago
    @281120856527077378

    thanks, without using beforeChange, the status is already draft





    should I use beforeChange as a security measure?



    to make sure no post gets published?

  • discord user avatar
    jarrod_not_jared
    3 years ago

    If you pass a query param of

    draft=false

    I believe it will skip creating the draft



    @944284724824801302

    did you give this a shot?

  • default discord avatar
    generator1013 years ago
    @281120856527077378

    not yet, but I will let you know if I stumble across an issue, thanks

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.