Like what we’re doing? Star us on GitHub!

payload cms scheduler

last month
1 2

I would ask if there is a standard approach for automatic, reoccurring actions in Payload? For example, when user is inactive since 7 days, deactivate him or similar things.

  • denolfe
    Payload Team
    last month

    We use node-cron in our public demo to clear the database and re-seed data every hour. Might be a good example to look at.

  • ChrisGV04
    last month

    I believe there's no built-in way to do that on Payload, however, since it's built on top of express and Node.js you are able to implement cron jobs and use the Payload Local API to achieve what you're looking for.

    You can look into node-cron for a simple cron job implementation in Node.js.

    For the use case you mentioned, maybe you can run a cron job once at the beginning of every day to check for any inactive users since 7 days or more and suspend them using the Payload Local API.

Open the post
Continue the discussion in GitHub
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More