In this video we will create an article that will be automatically unpublished at a time in the future.

Now, let’s enable articles to have a scheduled unpublish date.

  • Go to “Structure => Content types => Article” (admin/structure/types/manage/article)
  • Scroll down to the “Scheduler settings” vertical tab
  • “Unpublishing settings”
    • [x] Enable scheduled unpublishing (This will allow the content author to enter a date in the future when the article should be automatically unpublished.)
    • [ ] Unpublishing date/time is required (This will require the content author to enter a date in the future when the article should be automatically unpublished)
    • [ ] Create a new revision on unpublishing (This will create a new revision when the article is unpublished)
  • (Save content type)

Now, let’s go back and create an article that will automatically unpublish itself.

  • Go to “Content => Add content => Article) “node/add/article”
  • Title: Test Article #3
  • Body: Lorem ipsum...

This time when we scroll down, in the vertical tab “Scheduling options” I’m going to schedule this for one minute in the future to see how it works.

  • Unpublish on [date/time]
  • (Save)

This time, at the top of the page we only get one notice, the standard message that says the article has been created, and if we go home, we do see the new article because it is published. I’ll come back in just a minute after the time I scheduled it to unpublish.

...

Okay, now when we refresh the page, you’ll notice that the article is still there. As I mentioned earlier, this is because Scheduler utilizes Cron to publish and unpublish content. Since my cron is set to run every three hours, I’ll go ahead and run it manually to unpublish the content.

And now that cron has run, when I refresh, the article is unpublished. This works the same way publishing content with Scheduler does, in that even though you schedule something at a specific time, it will actually unpublish when cron runs. So if you schedule something to unpublish at 1:00, but cron doesn’t run until 2:00, the article will actually be unpublished at 2:00. So, if you’re dealing with time sensitive information, such as a banner for a sale that ends at midnight, you’ll probably want to utilize Scheduler’s lightweight cron functionality.

As I said before, you can create a separate cron schedule specifically for the Scheduler module so that it can check for content that needs to be published and unpublished on a more frequent basis, without running the full Drupal cron. Let’s take a look at how to use that now.