We love to say your Drupal website capabilities are unlimited, but even more than that we love to provide examples. One of them is the Drupal Rules module. It can be compared to a whole team of smart and tireless robot assistants that do necessary things at right moment on your website. They welcome your guests in, deliver important messages, remind you of events, and much more — from the simple to the most complicated scenarios. So let’s take a closer look at how the Drupal Rules module works to make Drupal’s strengths even greater.

The fundamentals of the Drupal Rules module

The Rules contributed module lets you set up automated workflows on your website based on so-called reactive rules, aka ECA rules. ECA stands for “event-condition-action.” So, you can create your reaction rules, each of which consists of:

  • an event
  • a condition
  • an action

The principle is: when some event takes place, and a certain condition is met, then a particular action is automatically triggered. For example:

  • Event: content is viewed by a user
  • Condition: the user role is Anonymous
  • Action: a message is shown on the site asking the user to log in to post comments

First, an event is created, and then the conditions and actions are added. In many cases, just an action is enough and the condition can be skipped — for example, users have logged in, irrespective of conditions, they can be shown a “welcome” message.

drupal rules module
 
drupal rules module
 
drupal rules module

The Rules module provides impressive lists of default events, conditions, and actions to select from. The lists depend on other modules that you also have installed. In addition, custom ones can be created by coding and added to your Drupal website.

Rules components are reusable, which means they can be added to other rules and even used by other modules.

To categorize your rules, you can use tags, which is very helpful when you have plenty of them on your website.

A few use cases of the Drupal Rules module

With the Drupal Rules, you can, for example:

  • remind a user to fill in the required fields before saving a node
  • thank a user for posting content
  • tell a user that the content is pending the moderator’s approval
  • notify the moderator about the newly posted content or comments
  • notify a user when someone comments on their content
  • notify a user when someone adds their content to bookmarks
  • remind a user about calendar events a certain time in advance
  • notify the administrators about emergency log entries
  • block a user for spamming or other bad behaviour
  • notify a user that a desired product is in stock
  • apply a discount on a product when it is applicable

and much more — as stated above, the sky is the limit to the possible workflows!

Cooperation with other Drupal modules

The Rules work closely with Drupal Commerce, Ubercart, Content Access, Flag, Organic Groups, Features, Token, Rules Link, Rules list conditions, Views Rules, Rules Forms, Conditional Rules, and many other modules, so the most interesting scenarios are provided.

The Rules module in Drupal 7 and Drupal 8

In Drupal 7, the Rules module requires the Entity API contributed module, while in Drupal 8, it needs the Typed Data to work with.

Its UI has also changed considerably. One of the main changes is that in Drupal 8 you do not see the traditional Drupal 7’s “Replacement patterns” link when specifying the Condition and Action values. You can put the values in either by data selection mode (which shows hints upon clicks on the field) or by direct input mode.

The Rules module in Drupal 7 and Drupal 8

The Rules in Drupal 8 is still in its alpha state, so it is not 100% ready for production sites. This is a complex module, so porting it to Drupal 8 is a cumbersome task.

To recap

The Rules module requires careful use and experience, especially when it comes to complex cases. That’s why it is better to entrust the Rules creation to a solid Drupal team.

They can also advise you what kinds of workflows can be created for your particular business goals. Whatever you need that might be missing in the default Rules features can be added by custom code.

For all this, you are welcome to contact our expert Drupal support firm!

 Get new blog posts by email:
Do you accept our Privacy Policy?