Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Implements hook_comment_insert().
- *
- * Send a message when a new comment is created to subscribed users.
- */
- function dc_subscribe_comment_insert($comment) {
- // must confirm $comment->status
- // Create a new message, assigned to the node author, and add a
- // reference to the comment, so we can later use tokens related to that
- // comment.
- $message = message_create('comment_message_v2', array('uid' => $comment->uid));
- $wrapper = entity_metadata_wrapper('message', $message);
- // Reference field to the comment on the message
- $wrapper->field_comment_reference->set($comment);
- // Reference field to the node that was commented on
- $wrapper->field_node_comment_reference->set($comment->nid);
- // Let Message-subscribe save and send notifications.
- message_subscribe_send_message('comment', $comment, $message);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement