What is Rules?

Last updated on
1 November 2021

Reaction Rules are sets of instructions for what to do when an event occurs on your web site. Some typical events that occur all the time are:

User logs in
Content is updated
A user Comment is added

The Rules module allows you to add functionality to your website by constructing your own Reaction Rules through a user interface. Reaction Rules consist of Events, optional Conditions, and Actions. The basic outline of this functionality is:

WHEN an event happens
IF conditions are right
THEN take an action

and you'll find that Rules gives you a wide variety of predefined events, conditions, and actions that you can use to customize what happens when users visit your website.

Let's first give a concrete, specific example to give you an idea of what this means, then we'll delve into the seemingly endless possibilities.

One Event provided by Rules is "After saving new content". That is, whenever a new page on your site is added, this event will occur. I hope you're already thinking of things you can do with this - what actions might you take when this event happens?

A common action is to "Send email". When the "After saving new content" event occurs you could notify a user that there's a new post, for example.

What about conditions? We said that WHEN an event happens, IF the conditions are right, THEN we take an action. With our example here, we might use the condition "Text comparison" to see if the new page contains a key word that we're interested in. Thus instead of sending mail for EVERY new page, we send the mail only for new pages that contain certain key words we're looking for.

We have just described a Reaction Rule:

Event: After saving new content
Condition: Text comparison
Action: Send email

These and many other events, conditions, and actions are automatically provided by the Rules module. Other modules that you install may define their own module-specific events, conditions, and actions. For example, Ubecart provides an event called "Customer completes checkout". You may also write your own events, conditions, or actions if you're so inclined; Rules is designed to give non-programmers the ability to change the operation of their web site, but even programmers find that using Rules is a quick and easy way to prototype and implement functionality that would be hard to otherwise accomplish.

Help improve this page

Page status: No known problems

You can: