hook_notifications_object_ENTITY_TYPE()
Last updated on
30 April 2025
hook_notifications_object_ENTITY_TYPE() returns, among other things, the available subscriptions for a particular entity. These will make their way into the subscriptions block.
For example, if you are viewing a node, then modules implementing hook_notifications_object_node() can specify which subscriptions will be available for users to subscribe to in the subscription block when viewing that node. Here's an example from og_notifications:
/**
* Implements of hook_notifications_object_node()
*/
function og_notifications_notifications_object_node($op, $node, $account = NULL) {
switch ($op) {
//...
case 'subscriptions':
// Return available subscription options for this node
$options = array();
if (array_keys(og_get_all_group_content_entity()) && notifications_content_type_enabled($node->type, 'group_content')) {
$options[] = notifications_subscription('group_content')
->add_field('node:gid', $node)
->set_group($node)
->set_name(t('All posts in this group.'));
}
return $options;
break;
}
}
This code tests for the $op being equal to 'subscriptions', and then instantiates the relevant subscriptions for any node that is a group node.
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion