Samuli Natri
Jul. 21, 2015
Updated: Sep. 28, 2016
By Samuli NatriJul. 21, 2015
(Updated: Sep. 28, 2016)

How To Expire Nodes With Rules Scheduler (Article + Video) (Drupal 7 Tutorial)

How to schedule nodes to be deleted with Rules Scheduler and let people postpone the expiry date with Flags. Users also get an expiration mail before the nodes expire.

Note: there are modules called Node Expire and Node Expire Extras that allows you to do something similar. However in more complicated scenario I used the solution shown here.

Install Modules

  • Install and enable these modules:
drush -y en rules rules_admin rules_scheduler flag

Create 3 Components

  • Go to Configuration > Workflow > Rules > Components > Add new component
  • Create an Action set component called Article : Send Expiry Notification:

  • Set DATA TYPE as Node. This is an input parameter for the component to act on:

  • Select Send mail action:

  • Switch to data selection:

  • Select node:author:mail as the recipient:

  • Add mail subject:

  • Add mail message:

  • Hit SAVE
  • Create another component in similar fashion but make it delete entity:

  • Add Delete entity action:

  • Select node as the Data selector.

  • Create the Third component that schedules the previous two:

  • Create and action and select Schedule component evaluation for Article : Send Expiry Notification component:

  • Expiry notification will be sent in 5 months and 2 weeks:

  • String to identify the task:

  • Hit SAVE
  • Do the same thing with Article : Delete component by adding another action:

  • Node will be deleted in 6 months (2 weeks after the expiry notification):

Create a Rule

Create a rule to set the schedules when article is created.

  • Go to Configuration > Workflow > Rules and add a new rule:

  • Add an action to set the schedules:

  • Create an article and you should see the schedules in Configuration > Workflow > Rules > Schedule

Create a Flag

Create a flag to update the expiry dates.

  • Go to Structure > Flags > Add flag
  • Select Nodes as flag type:

  • If you don't tick Global flag, then every user has individual flags for users.

  • Hit SAVE
  • Create a rule that reacts when node has been flagged:

  • Add action that sets the schedules (this will also update the schedules if they already exist):

  • Add another action to set the flag unflagged when you flag it:

  • In node (or teaser view) click the Update Expiry Date to test this:

  • Now in Configuration > Workflow > Rules > Schedule the tasks has been updated:

These tasks will be evaluated when cron runs. See the video where I test this out and use Views Bulk Operations (VBO) to set schedules for existing nodes!

Samuli Natri is the founder of He started building Drupal sites in 2010 with Drupal 6. He attended Helsinki University and Helsinki University of Technology (Social Sciences and Computer Science). Read more...


Hi, I wonder why you don't add tags to allow us to filter your tutorials.
Thank you

Tags are back! Thanks for reminding me ;) Not all content is tagged yet though.

Glad to see, I'm planning to learn many things in your amazing site.
vamos WDT ;)

This tutorial was extremely helpful for me to get started with Drupal rules and workflows, and specifically for expiring nodes. Thank you!

You're welcome!

Add new comment