How to use Rules to notify users about new or updated posts on a Drupal site?


If you want users to be able to "subscribe" to new or updated content that is posted on a Drupal 7 site, then usually these contributed modules get involved:

But these modules are either huge, or have some maintenance/support challenges.

Isn't it possile to create some custom rules (using the Rules module) instead?



1 answer


You could also use the Message module for this. So that you have the Rules module create message "entities" (which is what you get if you use the Message module). And then just use the power of Views to display those messages that got created in the format you need (page, block, etc).

Here is a blueprint of what you'd need:

  1. Define an appropriate Message type, using the Message module. Think of Message types as similar to "Content types", which will be used to create Messages, similar to Nodes. I'd imagine that the message text you'll want to use is similar to these messages that are created when using the Answers module (which is just "a" sample of a module that takes advantage of the Message module):

    Mon, 11/28/2016 - 16:54

    User Demo.User has offered a new answer to this question: What is Drupal's Message Stack and how do its modules work together?.

  2. Create a rule with a Rules Action "Create entity" (of type "Message"). Refer to the answer in 'Which user related token(s) can be used to create a Rule for setting up a message type?' for some examples, which are related to these variations of using Mentions:

  1. Make sure to also add a Rules Action to pass any relevant tokens, via Rules, as Replacement tokens that you can use in your Message type you created with the Message module. Refer to 'What's the purpose of "Replacement tokens" of a Message type?' for more details on this.

  2. Use Views to display the created messages in the format you prefer.

About the Message module

The Message module is an amazing module, which is at the bottom of the Message Stack. For more details about the Message Stack, refer to What is Drupal's Message Stack and how do its modules work together?.

Only using site building techniques you can create all sorts of messaging solutions in a Drupal site. But, there is not a lot of documentation about the Message module (neither for the Message Stack). Therefor it may help to get you started by looking at these questions (and their answers):

Friend of Rules and Views

The tutorial about "How to allow users to manage their own Message Stack messages?" explains how to use the Rules and Views modules as a natural complement of Message. Actually, the Message module does not come with something like a "UI" to perform operations on messages (view, delete, mark read, etc).

This tutorial also explains how, optionally, you can also use the Menu Badges module to implement Instant notifications. This will show the number of Unread Messages via a (red) counter (similar to like on iOS). For some examples of such instant notifications, refer to these questions (and their answers):