2

I have an event node type. The site needs to allow registered users to enable or disable notifications for this event. So on the event page (I have several views, etc) I would like to have a button is seen by registered users. It would be either show "Enable notifications" or "Disable notifications" based on its current value.

Ideally this would somehow associate the user and to the event (relation?) so that I can query db for all users who have enabled notifications for this event.

Any help or ideas on how to do this?

0

This kind of functionality is definitely something for which you should use the Flag module (at least). Using a flag that can be set by individual users (not a 'global' flag). Together with a few modules as further detailed below.

Message Stack

Have a look at the Message Stack, which consists of these modules (quotes are from the module's project page):

  • Message:

    The Message module is the core of the message stack. It enables logging and displaying system events in a number of different use cases. Events that are recorded over time are sometimes call activity streams. Exportable messages subtypes can be created for different use cases with custom fields and display (view) modes.

  • Message Notify.

    This module provides a method for sending a message via a notifier plugin. Message Notify comes with plugins for email and SMS and may be extended to other transport mechanisms as required.

  • Message Subscribe.

    With this module, users who subscribe to content will be notified when events occur that involve that content. The module leverages the Flag module, which provides a subscribe functionality to users.

These are the basic components and dependencies of the message stack:

enter image description here

If you want to have a closer look at the Message Stack in your own environment, then experiment a bit with the Answers module (disclosure: I'm a co-maintainer), together with the Answers Notification sub-module, which allows logged in users to subscribe to selected questions, so that they receive notifications (using the Message Stack) when Questions receive Answers.

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 it. And how, optionally, you can also use the Menu Badges module to show the number of Unread Messages via a (red) counter (similar to like on iOS).

Video tutorials

If you're not familiar (enough/yet) with Rules, checkout the 32 (!!!) great (+ free) video tutorials Learn the Rules framework, organized in 7 chapters.

There is a similar set of 8 video tutorials about the Flag module, often considered as a natural complement to the Rules module.

And a set of 30 video tutorials about the Views module.

  • Pierre, thanks again for your answer. You pointed me in the right direction. I would + but don't have points yet :).....have a great day – tavor999 Nov 1 '15 at 23:05
1

I would use the Flag module for this. It allows per user state toggling and integrates well with Views.

  1. Create a Flag called notify.
  2. Change the text that is shown to "Enable notifications" and "Disable notifications".
  3. Use Rules and Views to send out your notifications.

For extra credit create a View that shows a User all of the nodes they are receiving notifications on.

  • Thx the the answer, wasn't aware of this module – tavor999 Nov 1 '15 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.