Message hooks

  1. 1 privatemsg.api.php message_hooks
  2. 7-1 privatemsg.api.php message_hooks
  3. 7-2 privatemsg.api.php message_hooks
  4. 6-2 privatemsg.api.php message_hooks

All message-level hooks look like hook_privatemsg_message_op, where op is one of the following:

  • load: Called when a full message is loaded similar to nodeapi_load, new values can be returned and will be added to $message, parameter: $message
  • validate: Validation, before the message is sent/saved. Return validation errors as array, parameter: $message, $form = FALSE
  • presave_alter: Last changes to $message before the message is saved, parameter: $message
  • insert: message has been saved, $message has been updated with the mid and thread_id, parameter: $message
  • delete: the message is going to be deleted, parameter: $message
  • view_alter: the message is going to be displayed, parameter: $vars
  • recipient changed: a recipient is added or removed from/to a message.

In hooks with _alter suffix, $message is by reference.

$message is an array, with all the relevant information about the message. The information in there can be changed/extended by modules, but looks typically like this:

array (
  'mid' => 3517, // message id, identifies a message
  'author' => 27, // author id
  'subject' => 'Message subject',
  'body' => 'Body of the message',
  'timestamp' => 351287003, // unix timestamp, creation time
  'is_new' => 0, // If the message has been read by the user
  'thread_id' => 3341, // thread id, this is actually the mid from the first
                          message of the thread
)

File

./privatemsg.api.php, line 146
Privatemsg API Documentation

Functions

Name Locationsort descending Description
hook_privatemsg_message_flush ./privatemsg.api.php Is called when a message is flushed.
hook_privatemsg_message_validate ./privatemsg.api.php Validate a message before it is sent/saved in the database.
hook_privatemsg_message_presave_alter ./privatemsg.api.php Change the message before it is stored.
hook_privatemsg_message_view_alter ./privatemsg.api.php Act on the $vars before a message is displayed.
hook_privatemsg_message_insert ./privatemsg.api.php This hook is executed after the message has been saved.
hook_privatemsg_message_recipient_changed ./privatemsg.api.php This hook is invoked when a recipient is added to a message.