This tutorial will give you an example how to use the Rules Scheduler module.

Preparations

  1. At first you have to download and install the Rules module, the Views module (for displaying scheduled tasks) and the Token module.
  2. Go to "admin/build/modules" on your site and activate "Rules", "Rules Administration UI", "Rules Scheduler", "Views" and "Token" modules.

Creating a rule set as scheduling action

Now we need to create a rule set, that will be scheduled later.

  1. Go to "admin/rules/rule_sets" and click on the tab "Add a new rule set".
  2. Fill out the label for example with "Publish content {rule set}" and the machine-readable name with "publish_content".
  3. In the "Arguments" fieldset fill out the first row: select "Content" as data type, enter "Content {argument}" as the label and "publish_content__content" as the machine-readable name.
  4. Now confirm your input by clicking the "Save" button.
  5. You are redirected now to the rule sets overview page and your freshly created rule set is listed.
  6. Click on it ("Publish content {rule set}" was the name) and add a new rule by clicking the "Add new rule" tab.
  7. Fill out the label of the new rule with "Publish action {rule}" and click on "Save changes".
  8. You are now on the edit page of this rule and we want to add an action by clicking on "Add an action".
  9. You get a select box where you need to select "Node|Publish content" (NOT "Rule Set|Publish content"!) and confirm it by clicking on "Next".
  10. We leave the details of the action unchanged on the received form, because the argument is already selected correctly (we had only "Content {argument}" specified as argument), except for changing the action label from "Publish content" to "Publish content {action}" to make it easier to track.
  11. Hit "Save".

Creating a triggered rule

Our simple rule set is now completed and is ready for scheduling.

  1. To trigger it, we need to invoke it on a certain event, so we go to the triggered rules page ("admin/rules/trigger") and click on "Add a new rule".
  2. Fill out the label with "Publishing rule {triggered rule}" and select "Node|After saving new content" from the event box.
  3. Hit "Save changes" to create the rule. On the resulting page click "Add an action", where we will schedule our rule set.
  4. Select "Rule Scheduler|Schedule Publish content {rule set}" from the select box and confirm the action by clicking "Next".
  5. Now we adjust the scheduling information: Append "{action}" to the label at the top. The arguments configuration is already setup correctly ("created content" is the item we want to hand over to our "Publish content {rule set}" rule set).
  6. The fieldset "Token replacement patterns" allows you to use substitutes for example in the "Identifier" field below.
  7. We want to identify the future scheduling task somehow, so we fill out the Identifier field with "node [node:nid]" to get the node ID of the created content. An identifier is always optional, but it is useful to delete/update a specific scheduled task later by another rule.
  8. We set "Scheduled evaluation date" to "+1 day", because we want the rule set to be executed one day after the creation event. Click on "Save" to submit the form.
  9. In order to trigger this action only for unpublished content, we need to add a condition. Click on "Add a condition", select "Node|Content is published", and click on "Next" to confirm the selection.
  10. Turn the "Negate" checkbox on because we want to trigger for content that is not published. Click on "Save" to submit the form.

Testing

At this point we are ready to do a little test.

  1. Create new content (e.g. on "node/add/story") and unset the "Published" option in the "Publishing options" fieldset.
  2. After saving, go to the rule set scheduling page ("admin/rules/rule_sets/scheduling").
  3. You can see now a task entry in the task list that contains a scheduling date in 24 hours and the identifier is set to the node ID of the new content.

Comments

beautifulmind’s picture

I am not a critic of this method but just wanna share my ideas with the community. The same feature can be achieved with workflow module.

Regards.

Regards.
🪷 Beautifulmind

levsoroka’s picture

I tried workflow module 7.x-1.0 had a bug with when came to scheduling time to change state. Updated to 7.x-1.1 that version has other bugs.

johnv’s picture

There is a new version of Workflow: 7.x-2.0. All known problems in the issue queue have been resolved.

achilles085’s picture

can this module do what i want?

ex.
I have a node created, which is initially unpublished state. when this node turns into published state, can this module turns the state of the node into unpublished again after 2months(60 days). What I'd like to do is i have this Listings(content type) and after the 2months period, this listing(node) will turn into unpublished state.

Badly needed your advice!

thanks

BassPlaya’s picture

Authentically,
BassPlaya

a.bond’s picture

How do we use "Views" to display scheduled tasks?

BassPlaya’s picture

I tried this to "unpublish a content" after a certain time (I still have to see the result, will let you guys know if it did the trick) but at some point the user might want to change the content. This update of the content does not affect the scheduling time. Would there be a way to do this? And how about when the rule is actually unpublishing my content, could the rule be set again when the content is published again in the future?

Authentically,
BassPlaya

tryitonce’s picture

Introduction:
In this example we want to add to an authorized user a specific role. In this example we want to add the role of “Contributing Member”.
Why? The idea is that a user’s role is changed based on certain actions he / she performs. Let’s say a user adds contents and for this she / he receives a bonus by upgrading the role allowing the user to do / access more content.
.... the full text has been here for too long - it is time to move it to it's own place in the list of the tutorials - see here - Tutorial 18: Role upgrade/downgrade based on user activity

cookiesunshinex’s picture

I would like to schedule an action to email the author of a specific node type if the node has been published within a certain period of time - let's say 1 hour for this example.

Let's say that we check to see if a node is of a certain type
Then we check to see if it is published
Then we check to see if it has been published within the last hour.

IF all conditions are met, then it emails the author of the post..

Please note that I'm not concerned with the creation date or save date, but when the node was published.

redben’s picture

What about basic data types ? i have a rule set that has a number argument (named and labeled nid). It contains a rule that has an action load content by id. The form for this action has a textfield, the token lists doesn't show any token for the argument is it normal ? all it shows is are the default tokens ([nid:site-login] [nid:site-logo] ..etc)
Any help would be much appreciated...

emerygjr’s picture

Is it possible to create a new revision of a node and schedule it for review but keep the latest published node active.

What I would like is to continue displaying the current version of the content until the new revision is approved. When this happens the prior version becomes un-published and the new version is published. I would like the current version to continue to be displayed until the revision goes through review and publication.

Thanks

Emery Gordon

Emery Gordon

tryitonce’s picture

As I understand it each node is an entity and when a revision takes place this one node is revised.

Thus I would expect that you have to work with 2 nodes.
The current published node is say .../breakfast-menu.
You could use the clone module - http://drupal.org/project/node_clone - and create a copy of this and make your changes, keep it unpublished. When it is reviewed you would need first create a back-up or versioned revision of .../breakfast-menu - add the date for example = .../breakfast-menu-07-04-2010; then you can rename the cloned and amended node to .../breakfast-menu.

You could also look at the version process - there are several modules and Drupal seems to be using something to control the revisions of modules - but I have no idea about that - try http://drupal.org/project/modules?page=1&text=version or better this - http://drupal.org/project/modules?text=node%20version%20control - gets you
http://drupal.org/project/versioncontrol_soc08
and http://drupal.org/project/versioncontrol
and as a tool http://drupal.org/project/views_bulk_operations might be useful.

Good luck ...

tryitonce’s picture

Just came across this: http://drupal.org/project/content_moderation.

It is not relevant for me now - but might help here.

Good luck ....

tovica’s picture

An error occured during rule evaluation. It follows the evaluation log:

* 0 ms "Content is going to be saved" has been invoked.
* 0.652 ms Executing the rule "pada saat buyer create content tenders" on rule set "Content is going to be saved"
* 2.621 ms Loaded variable "acting user"
* 3.314 ms Condition "User has role(s)" evaluated to FALSE.
* 3.419 ms Executing the rule "change role" on rule set "Content is going to be saved"
* 3.619 ms Condition "Saved content is Profile" evaluated to FALSE.
* 3.719 ms Executing the rule "ganti roles" on rule set "Content is going to be saved"
* 3.933 ms Loaded variable "unchanged content"
* 4.052 ms Condition "Saved content's field 'field_profile_type_member' has been changed" evaluated to FALSE.
* 4.142 ms Executing the rule "pada saat akan save new content profile" on rule set "Content is going to be saved"
* 4.339 ms Condition "Saved content is Profile" evaluated to FALSE.
* 4.428 ms Executing the rule "publish content with sched" on rule set "Content is going to be saved"
* 4.614 ms Condition "Saved content is News" evaluated to TRUE.
* 24.163 ms Action execution: "Publish content {rule set}"
* 25.028 ms Packing arguments for scheduling the rule set rules_publish_content failed.
* 25.746 ms Evaluation of "Content is going to be saved" has been finished.

tryitonce’s picture

You should discuss this in one of the forums or under the issues of the project. Here the tutorial is discussed - not really problems.

Add you query to one of the relevant forums and put a link here to that forum - rephrase one of the titles enough not to have a double posting.

You also need to add the module, some more background including the version etc.

makbul_khan8’s picture

Hey...

This tutorial actually works...
But can anybody display the link of this tutorial as an video link......
Thanks.

makbul_khan8’s picture

hello friends

I am new to DRUPAL Can any body help me in creating a simple rule.
The Scenario is as follow.

I want to pop-up a window, which accepts a email id of user when anonymous user clicks on Login Link.

you can also reply........ with some similar scenario

Thank You.

jarush’s picture

It does not work for me.
I followed this Tutorial step by step, I just changed "+1 day" to "+1 minute", and I did see a task entry in the task list(admin/rules/rules_sets/scheduling) after I created a new content that no published.
But, It did not publish the content after 1 minute later..
Why?

itserich’s picture

I tried it with 1 minute and 1 hour and it worked for me.

It is complicated for me but eventually it worked.

Good luck.

dhakshinait’s picture

In my site, i have one content types called " catalogue ", initially i have unpublished them. if any user create new "catalogue" content means, it has to send a email to me to get approval from me to publish that content. please help me.

LandonAB’s picture

I realize Rules 2 is in beta but trying to apply this tutorial to Rules 2 is impossible for someone new to Drupal. Are there any tutorials specific to Rules 2? I am trying to learn this but Rules 2 is so different (example, where is admin/rules/trigger?) that it's impossible for me to figure it out.

Thanks,

Landon

manooh’s picture

This worked for me in Drupal 7:

Creating a rule set as scheduling action

  • Go to admin/config/workflow/rules/components/add
  • select "Rule set", hit "continue"
  • name: "Publish content"
  • data type, first row: data type "Node", name/machine name "node", usage "parameter"
  • click "Continue"
  • click on "Add Rule"
  • name "Publish action", click "Save changes"
  • click "Add action", select "Node > Publish content", click "Save"

Creating a triggered rule

  • Go to admin/config/workflow/rules/reaction/add
  • Name "Publishing rule", react on event "Node > After saving new content"
  • click "Save"
  • click "Add action", select action "Rules scheduler > Schedule component evaluation"
  • Value: "Publish content", click "Continue"
  • Value "+1 day", data selector "node"
  • click "Save"
  • click "Add condition"
  • select condition "Node > Content is published", check "negate"
  • click "Save"
Abhishek Sawant’s picture

To trigger above rule do I need to run cron to publish the content or it will automatically gets content published. Please suggest.

Abhishek Sawant
Drupal Developer

Hardrocker’s picture

Great tutorial! But there is one problem. This allows us to automatically publish content 24 hours after it was created. What happens when we want to publish content at a specific time. Lets say at one minute past midnight (12:01:00) when the system is scheduled to publish the content for that day? Especially when used in conjunction with http://drupal.org/node/175414 I have not found any documents nor support for this. Would love to see this happen. Please advise.

itserich’s picture

Have you tried scheduling a publish Rule Set for 12:01 am leaving the date blank?

Not sure it would work, just a thought.

There is a Rules Group, might have better luck posting questions there.

Hardrocker’s picture

Nope that didn't work. I'm reading where if there was no argument set you can manually specify the publishing time. But the the rule sets required the arguments so there is no way to manually specify the time.

tryitonce’s picture

Would it work by using some form of date formula and incrementing it by 1. The new day (date) starts at 12:00:01 ... ?

Just a thought - without time to play with it myself ....

bartl’s picture

Nowhere is explained what the stuff between curly braces is for. Yet it appears to be very important.

I followed this "tutorial" (it's not a tutorial, it's a walkthrough) step by step, although I might have made a mistake; and it would appear to be working, except the scheduled rule doesn't have a unique name and thus it'll be replaced as soon as another node is saved. And I have no idea how to fix it.

There's no chance in hell I could ever adapt this to what I want to do with it.