Message hooks in Privatemsg 7
Same name and namespace in other branches
- 6.2 privatemsg.api.php \message_hooks
- 6 privatemsg.api.php \message_hooks
- 7.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 similiar 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' => 'raclebugav', // Message subject
'body' => 'bla bla', // 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 | Location | Description |
---|---|---|
hook_privatemsg_message_flush |
./ |
Is called when a message is flushed. |
hook_privatemsg_message_insert |
./ |
This hook is executed after the message has been saved. |
hook_privatemsg_message_presave_alter |
./ |
Change the message before it is stored. |
hook_privatemsg_message_recipient_changed |
./ |
This hook is invoked when a recipient is added to a message. |
hook_privatemsg_message_validate |
./ |
Validate a message before it is sent/saved in the database. |
hook_privatemsg_message_view_alter |
./ |
Act on the $vars before a message is displayed. |