function hook_privatemsg_block_message in Privatemsg 6.2
Same name and namespace in other branches
- 6 privatemsg.api.php \hook_privatemsg_block_message()
- 7.2 privatemsg.api.php \hook_privatemsg_block_message()
- 7 privatemsg.api.php \hook_privatemsg_block_message()
Check if the author can send a message to the recipients.
This can be used to limit who can write whom based on other modules and/or settings.
Parameters
$author: Author of the message to be sent
$recipients: Recipient of the message
$context: Additional information. Can contain the thread_id to indicate that this is a reply on an existing thread.
Return value
An indexed array of arrays with the keys recipient ({type}_{key}) and message (The reason why the recipient has been blocked).
Related topics
3 functions implement hook_privatemsg_block_message()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- pm_block_user_privatemsg_block_message in pm_block_user/
pm_block_user.module - Implements hook_privatemsg_block_message().
- privatemsg_limits_privatemsg_block_message in privatemsg_limits/
privatemsg_limits.module - Implements hook_privatemsg_block_message().
- privatemsg_privatemsg_block_message in ./
privatemsg.module - Implements hook_privatemsg_block_message().
5 invocations of hook_privatemsg_block_message()
- privatemsg_forward_form_validate in privatemsg_forward/
privatemsg_forward.module - Validate function for forward form.
- privatemsg_get_link in ./
privatemsg.module - Returns a link to send message form for a specific users.
- privatemsg_message_change_recipient in ./
privatemsg.module - Add or remove a recipient to an existing message.
- _privatemsg_get_allowed_recipients in ./
privatemsg.pages.inc - Check if the current user is allowed to write these recipients.
- _privatemsg_validate_message in ./
privatemsg.module
File
- ./
privatemsg.api.php, line 414 - Privatemsg API Documentation
Code
function hook_privatemsg_block_message($author, $recipients, $context = array()) {
$blocked = array();
foreach ($recipients as $recipient_id => $recipient) {
// Deny/block if the recipient type is role and the account does not have
// the necessary permission.
if ($recipient->type == 'role' && $recipient->recipient == 2) {
$blocked[] = array(
'recipient' => $recipient_id,
'message' => t('Not allowed to write private messages to the role authenticated user'),
);
}
}
return $blocked;
}