Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Drupal Site Configuration: Triggering Actions

The Actions section under the System section of the Drupal Configuration page shows you a list of available actions and allows you to create custom actions. An action is some event that happens in response to something. For example, when a new user registers on your site, sending him an automatic e-mail is considered an action.

The missing piece here is a way to actually use these actions. Behind the scenes, Drupal has code built-in that triggers these actions; for example, in the code for new users registering is a trigger that fires off the e-mail action.

The way you can use actions without having to write the code to trigger them is to use the Trigger module — which is an optional Core module that must be enabled before you can use it.

Here's a basic example of how to create a trigger to display a custom message to a user who signs in. You must first create a custom action by following these steps:

  1. Choose Configuration→System→Actions.

  2. From the Create an Advanced Action drop-down list, choose Display a Message to the User and click Create.

  3. In the next screen, type your message in the Message text box.

    In the example, the following was typed: Hi [user:name], it's good to see you. Let's do lunch sometime.

    image0.jpg

    The [user:name] is a stand-in for the name of the user who just logged in. In other words, if a user with the username Elmer logs in, after you trigger this action, that user will see the message, Hi Elmer, it's good to see you. Let's do lunch sometime.

  4. Click Save.

    The other half of this operation is to set up a trigger to fire off this action when a specific user logs in.

  5. Enable the Trigger module from the Modules page.

  6. Choose Structure→Triggers.

    The Triggers page has five tabs along the top. These correspond to the types of activities that happen on your site.

  7. Click the User tab.

    Because you want something to happen when a user signs on, the trigger you want is under the User tab.

    image1.jpg
  8. Under the trigger After a User Has Logged In, select Display a Message to the User from the drop-down list.

  9. Click the Assign button next to the drop-down list.

Now when a user logs in, he or she will see the message, with the correct username substituted for the [user:name] you put in the action.

To delete a trigger, click the Delete link next to it.

blog comments powered by Disqus
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.