Book Image

Drupal Rules How-to

By : Robert Varkonyi
Book Image

Drupal Rules How-to

By: Robert Varkonyi

Overview of this book

Rules is what every Drupal site builder and developer has to use when creating event ñ action-based applications. The framework provides a highly flexible way to create sophisticated, condition-based functions any Drupal based system into an interactive application. Rules makes Drupal rule the CMS world."Drupal Rules How-to" is a practical, hands-on guide that provides you with a number of clear step-by-step exercises, which will help you take advantage of the real power of the Rules framework, and understand how to use it on a site builder and developer levelThis book demonstrates the power and flexibility of the Rules framework. It discusses the main aspects of the module both from the site builder and developer perspective, from basic and advanced Rule configurations using Events, Conditions, Actions and Components to getting familiar with the Rules API. You will also learn how to use additional modules together with Rules to further extend the possibilities of your Drupal system, such as Rules Scheduler to schedule the execution of your Rule configurations and Views Bulk Operations to execute Rule configurations on a view result list. The book also demonstrates the main API features that enable you to create your own Events, Conditions and Actions, provide new data types to Rules and execute your configurations programmatically
Table of Contents (7 chapters)

Sending e-mail notifications (Must know)

This recipe explains how to send a customized e-mail notification to administrators when a new user registers on the website.

How to do it...

  1. Create a new rule configuration and set the event to User | After saving new user account.

  2. Add an action System | Send mail to all users of a role.

  3. Select the role you want the e-mails to be sent to.

  4. Enter the subject of the mail in the Value section under SUBJECT.

  5. Enter the body of the e-mail in the MESSAGE | Value section.

How it works...

In this rule configuration, we're telling Rules to act on new user registrations and send e-mail notifications to the site administrators when this event occurs. In the e-mail body we've used REPLACEMENT PATTERNS to display the new user's username, the date and time the account was created, and the site's name will be used as the signature.

There's more...

While this example is very useful and easy to configure, site builders are advised to use it with care. It is not advised to use this action to send e-mails to a large number of users. Because every action is executed right after an event occurred, it can put a serious load on the server(s) and can cause the site to go down.