How to use message_subscribe with organic groups
This is meant to be a reasonable tutorial for using message_subscribe with organic groups as the module exists as of (2014-02-25), but you
The Message Subscribe module provides a mechanism for users to tell the system to send them notification messages when events occur on a web site. When this module is enabled the Message stack becomes a viable alternative to the Messaging and Notifications modules.
Message Subscribe leverages the powerful Flag module and its rich API. The Flag module allows administrators to configure flag entities for a variety of entity types including nodes, comments, and users.
Message Subscribe determines the context of the message (comment, node, group etc) and collates all users who have subscribed to (flagged) objects in this context. The message_subscribe_send_message function determines which users have subscribed to an item of content and then calls message_notify_send_message to notify each of the users. Message Subscribe also includes a couple of useful hooks that allow developers to modify the list of subscribed users at the time it is being collated from a given context.
/*
* Implements hook_node_insert().
*/
function foo_node_insert($node) {
$message = message_create('foo_message_type', array('uid' => $node->uid));
$wrapper = entity_metadata_wrapper('message', $message);
$wrapper->field_node_ref->set($node);
// Replace explicit notification with subscription-based notification
// message_notify_send_message($message);
if (module_exists('message_subscribe')) {
// If Message-subscribe exists, let this example module use it.
message_subscribe_send_message('node', $node, $message, array('email' => $options));
}
}
As with Message Notify, this module supports scalable solutions through the optional use of the DrupalQueue API, which registers messages to be batch processed at a later time.
Finally, Message Subscribe comes bundled with Message Subscribe UI, which creates views that support the management of subscriptions from a tab on a user's account page.
This is meant to be a reasonable tutorial for using message_subscribe with organic groups as the module exists as of (2014-02-25), but you