Unpublishing a Node on Drupal: "Rules" vs. "Node Expire"

Friday, January 30th, 2009
Last Updated:
Sunday, April 05th, 2009

Disclaimer: Accessing the information on this page means you agree to the Sites Terms of Service

I recently created a classified website (Jan 2009) that is dedicated to used asphalt equipment. One of the features I wanted on the site, was the ability to transparently expire a node after x days (45 to be exact). The well known craigslist.org has a similar feature where a post would expire after 45 days but they recently changed it to 30. I'm guessing there are so many posts being put out that most people only look at the first few days.

Anywho, I wanted the ability on the site, for a mass number of users to create a post and have the post / node automatically expire after 45 days. Not knowing the power of the Rules module, I went in search of a module that would expire a node after a set time that I specified. Thats when I came across the Node Expire module.

After some extensive playing with both modules, I finally decided to go with the rules module because it will allow a node to transparently be unpublished without any say-so or input from the user. I didn't want them to mess with the expiration at all.

So, what exactly is the difference between the Rules and Node Expire Modules?

Rules is a very powerful module that allows certain "Actions" to happen on a Drupal site, after certain "Conditions" are met. I first setup a rule set that would unpublish a content type (post). Then I setup two rule triggers, one that says "When content is created, schedule the unpublish rule set" and another that says "When content is unpublished, then published, schedule the rule set". These are done at the system level where the user doesn't even know it's happening nor can they make any changes to how it operates. Use Rules to unpublish a node if you have a lot of users and you don't want them to set their own expirations. Keep in mind though that "powerful = complicated"... Rules isn't exactly for the faint-at-heart and will take some trial and error to get it right. I recommend setting up a sandbox to play with rules before implementing it on a production site.

Node Expire is designed for a site where there is only one (or a handful) of administrative persons and they all have the ability to set an expiration for a node. OR, a site where the user might need explicit permissions to set their own node expiration. A user who does not have the permission to set the expiration time, will be presented with an error saying that the post can't be created after an expiration date. I'm sure it is a bug that needs worked out, but basically, Node Expire won't allow (at this time) transparent expirations of nodes.

Version 2x of the Node Expire module will also integrate into Rules to give even more options for the expiration of a node, but I have not had very good luck in getting it to work on a site where I don't want the user to have access to node expirations.

At the time of this writing I had been testing the following versions:
Rules: v6.x-1.x-dev-[2009-Jan-16]
Node Expire: v6.x-2.02

Post Comment


Also, there is Auto Expire module: http://drupal.org/project/auto_expire

which lets only to renew node, without specifying exact expire date.

I think Auto Expire was another module I ran across in searching for various methods and I believe the main reason I didn't go with it, is the lack of continual support on the module. I prefer to setup my sites so they can be easily upgraded without sacrificing functionality from unsupported modules... Thanks for the tip though! Auto Expire might just be the "cats meow" for someone else!

By the way, Node Expire permits to set up "default expiration date" in special php format, for example "+30 day" or "+2 month", then in "Publishing options" the default value will be what you need, the problem could be if you want to restrict user to change the date.

"The problem could be if you want to restrict user to change the date." Ya, this is the main reason I didn't want to go with Node Expire. Giving my users access to the expiration of a node wasn't really what I wanted, and that's why I went with the Rules method. I will say however, that Node Expire is perfect for a single admin type of site, but I just couldn't use it in my environment. It might be different now though; I haven't tried it in a while.


How did you check if it was unpublished and then published again? I got it to unpublish a new content but not sure how to check if its been republished already...


Since I have the "auto unpublish" setup on a classified site, I ended up setting up a view for each user, to show them a list of their posts. One of the view fields I enabled, was whether or not the node was published, which gives a "yes" or "no" when the view is output. This lets the user know whether their post is "live".

There are really two main ways you can check to see if the nodes are unpublished:

1) Create a view that shows whether the node is published or not
2) Go to the Content List "http://yoursite/admin/content/node" and filter whether or not the node is published. This is actually the easiest method for just doing a quick check.

Hope that helps!

On other quick note, I have my site setup so rules will send me an e-mail every time a new post is published or an existing post is re-published. I did this initially to test to see if my "unpublish / re-publish" was working properly and just never shut it off. It lets me know things are happening on the site :) I can't remember exactly, but I want to say I had it setup to send me an e-mail on unpublish as well as new post & re-publish, but I turned off the unpublish e-mails.

For my users, I'm using Views Bulk Operations to give them the ability to check off 10 posts at a time, choose "repubish" and have all 10 re-up at the same time. (instead of editing each post 1-by-1.)


nice thing .. I tried very long to get it working via a rule set and didn't know where the scheduler comes into play.
But now it works, thank you very much! :)

Bye, Chris

I know that is possible, but how to make it step by step ?

The same decision I came to, but I can't make it work! I have spent at least 5 hours combing through drupal.org's documentation (forums, issues, groups, handbook, etc). I have found dozens of posts by Rules users begging for a solution, but no response that answers how to do it.

If you could post or send me instructions on how to get rules to do this, I will write some clear documentation that even a beginner can follow and post it to the Drupal site and the drupal documentation team.

How to make this with the help of rules?
I know that is possible.