We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43864
    • 151 Posts
    Hey, does anybody knows if it's possible to have a sort of timer on a resource to delete the resource after certain time. (without need of the admin or being logged in)

    I know there's the status published, and I can manipulate that, but I want the resource to be gone after certain time.

    Any idea?

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      A plugin connected to OnDocUnpublished could set the deleted field.

      This single line should do it:

      $resource->set('deleted', true);


      Then, it could query the DB for any docs set as deleted and remove any with an old enough deletedon date. That would be a little more complicated, but quite doable.

      Or, you could just empty the trash periodically.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 40641 ☆ A M B ☆
        • 56 Posts
        Do you mean even if the resource is published, sitsol. So any resource, regardless of status, to be deleted after a specific amount of time after it's publish date?
          • 43864
          • 151 Posts
          Quote from: chrischerrett at Oct 22, 2014, 03:13 PM
          Do you mean even if the resource is published, sitsol. So any resource, regardless of status, to be deleted after a specific amount of time after it's publish date?

          Yes, it's depending on the published status. It has to do with client-made pages (through the front-end). There the client can decide to unpublish the page. I would like to set on that moment a timer that after certain time, if the status does not change, the resource will be deleted (and the clients gets an email if possible).
            • 3749
            • 24,544 Posts
            I think my suggestion above would do exactly what you want, but maybe I'm misunderstanding you.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting