I want to allow my users to define their own subscription of a given taxonomy term appearing in a given organic group. I tried to do this by reusing subscription fields defined in notifications_tags module and og_notifications module using the following code:
function my_module_notifications($op, &$arg0 = NULL, $arg1 = NULL, $arg2 = NULL) {
switch ($op) {
case 'subscription types':
$sub_types['group-term'] = array(
'event_type' => 'node',
'title' => t('Group term'),
'description' => t('Subscribe to posts, in a given Group, tagged with a particular Term.'),
'access' => 'subscribe to group term', // define this permission in hook_perm()
'fields' => array( 'tid', 'group' ),
);
return $sub_types;
}
}
I have these results in the UI, which make me think I'm on the right track:
- "Group term" checkbox at /admin/messaging/notifications/subscriptions
- "Group term" checkbox at /admin/messaging/notifications/subscriptions/content
- "Group term" checkbox at /admin/messaging/notifications/subscriptions/ui
- Subscription creation page at users/%/notifications/add/group-term
But I know I'm missing something fundamental because events that conform to user-defined "Group term" subscriptions do not generate notifications. Please could someone tell me what else I need to do?
[Note: I commented a related thread here #897428: Subscribing to content type tied to taxonomy term/tag OR Vocabulary with something very similar to this post.]
Comments
Comment #1
crantok commentedJust in case anyone is searching for the same, or similar, thing...
I've succeeded in defining a subscription type for content tagged with a given taxonomy term and posted in a given organic group. I've made the module available via my drupal.org sandbox. It's very rough at the moment and definitely not fit for production sites, but it works.
The main thing I found was that I could not successfully reuse fields from other modules. On the other hand I could reuse an 'object type' defined in another module. (I reused the 'term' object type defined in the notifications_tags module.)
This has been a learning experience for me, as part of which I wrote these example modules to help me get to grips with the Notifications system. They are very heavily commented so they might help someone trying to define their first subscription type. Please note that I am still no expert on the Notifications system and I expect that an example module written by someone who was would look very different :)
Comment #2
rjbrown99 commentedThanks for the sample code, quite helpful. I'm going to try to use it as a base for #597776: Feature: Integrate with user relationships module.