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.

filtering documents that show up in admin panel (without limiting public read access).

default discord avatar
ryoheiwlast year

For collection level access, you can limit which users can read or provide a where query to allow only specific documents to be read. I'd like to keep public read access to the entire collection, but provide a where query for the documents that show up in the admin panel for the collection. Specifically, I want to be able to limit the documents based on a field on the user and document, kind of like a filterOptions from a relationship field but for the admin panel's documents (not overall collection reads). Is there a way to do this?



you can do this with JS if statements 🤦‍♂️ just filter when the user is signed in and return

true

for whatever web client you're using.



if (user && user.role === "user") {
        return {
          id: { equals: user.company.id },
        };
      }
      if (user && user.role === "admin") {
        return true;
      }
      return true;
    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.