HowTo: Integrate Privatemsg with Application toolbar (AppBar)
Last updated on
30 April 2025
The following code sample shows you how to integrate Privatemsg with the Application Toolbar.
/**
* Implements hook_privatemsg_message_insert().
*
* Adds a notification for each recipient when a message is sent.
*/
function yourmodule_privatemsg_message_insert($message) {
$text = t('!user sent you a private message', array('!user' => theme('username', $message['author'])));
$alert_type = 'privatemsg-receipt';
foreach ($message['recipients'] as $recipient) {
appbar_set_message($text, $alert_type, $recipient->uid);
}
}
/**
* Implementation of hook_appbar_id().
*/
function yourmodule_appbar_id() {
return array(
'privatemsg-receipt' => t('Privatemsg receipt (alerts recipient)'),
);
}
More information:
Privatemsg API documentation: http://blog.worldempire.ch/api
Application Toolbar API documentation: http://drupal.org/node/546536#api
Application Toolbar Integration examples: http://drupalcode.org/viewvc/drupal/contributions/modules/appbar/appbar_...
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