Private Messages

Enables private messaging between users with threaded conversations, user blocking, tagging, and email notifications.

privatemsg
3,431 sites
29
drupal.org

Overview

Private Messages is a comprehensive private messaging module for Drupal that allows users to exchange messages directly with each other. The module implements a threaded conversation system where messages are grouped into threads, supporting both one-on-one conversations and group chats with multiple participants.

The module provides a full-featured messaging experience including message composition with rich text formatting, read/unread status tracking, thread tagging for organization, user blocking capabilities, and configurable email notifications. Users can manage their conversations through a dedicated inbox interface with filtering and bulk operations powered by Views Bulk Operations.

For developers, the module offers a robust API service for programmatically creating messages and threads, along with hooks for extending block/unblock functionality. The module also includes migration paths from Drupal 6 and Drupal 7 Private Message modules.

Features

  • Threaded private messaging system with support for one-on-one and group conversations
  • Rich text message composition with configurable text formats
  • Read/unread status tracking with visual indicators for new messages
  • User blocking system to prevent unwanted messages, with configurable unblockable roles
  • Thread tagging using taxonomy terms for organizing conversations
  • Email notifications for new messages (configurable per user)
  • Bulk operations support via Views Bulk Operations (mark read/unread, delete, change tags)
  • User avatar display in message threads with fallback to default images
  • Leave chat functionality for group conversations
  • Role-based messaging permissions to control who can send messages
  • Moderator role configuration for handling complaints
  • Automatic deletion of removed messages after configurable days
  • User profile integration allowing users to enable/disable messaging
  • Send private message link on user profile pages
  • Unread message count in account menu with lazy loading
  • Programmatic API for creating messages and threads
  • Migration support from Drupal 6 and Drupal 7

Use Cases

Community Forum Private Messaging

Enable private communication between forum members. Users can send direct messages to each other, discuss topics privately, and block unwanted contacts. Moderators can receive complaints about inappropriate messages.

Customer Support Communication

Allow customers to communicate privately with support staff. Configure support roles as unblockable so they can always reach customers. Use tags to organize support threads by topic or status.

Team Collaboration

Enable group messaging for project teams. Multiple users can participate in a single thread, share updates, and receive email notifications for new messages.

E-commerce Buyer-Seller Messaging

Allow buyers and sellers to communicate about products or orders. Users can block spammers while maintaining open communication with legitimate contacts.

Programmatic Notifications

Use the API service to send automated private messages from custom modules. For example, send welcome messages to new users or notification messages about content updates.

Tips

  • Use the taxonomy tagging feature to organize threads by project, priority, or category for easier management.
  • Configure email notifications at the site level and let users opt-in/out in their profiles for flexible notification preferences.
  • Set up a moderator role and configure it in settings to allow users to report inappropriate messages.
  • For high-traffic sites, consider adjusting the 'Remove deleted messages' days setting to balance storage usage with audit requirements.
  • Use the Devel Generate plugins to test with large message volumes before going live.
  • The programmatic API (privatemsg.common service) allows integration with custom modules for automated messaging.
  • Place the Private Messages block in a sidebar for quick access to the inbox without navigating to the full page.

Technical Details

Admin Pages 7
Private Messages Settings /admin/config/content/privatemsg-settings

Configure global settings for the Private Messages module including message retention, allowed roles for messaging, moderator assignment, and which roles cannot be blocked.

PrivateMsg Message Settings /admin/structure/privatemsg-message

Entity settings page for the Private Message entity type. Allows configuration of field display settings for messages.

PrivateMsg Thread Settings /admin/structure/privatemsg-thread

Entity settings page for the Private Message Thread entity type. Allows configuration of field display settings for threads.

Private Messages (Inbox) /messages

User-facing inbox page displaying all private message threads. Includes exposed filters for searching by subject, members, and tags. Supports bulk operations via Views Bulk Operations including mark as read/unread, delete, and change tags. Shows thread subject, participants, last update time, message count, and tags.

Write new message /messages/new

Form for composing and sending a new private message. Users can specify one or more recipients, an optional subject, and the message body.

Blocked users /messages/blocked

Manage users that are blocked from sending you private messages. View currently blocked users and block additional users.

View Message Thread /messages/view/{thread_id}

Displays a full message thread with all messages, participant information, tags, and a reply form. Shows user avatars, timestamps, read/unread indicators, and provides actions for blocking users and deleting messages.

Permissions 7
Administer privatemsg message settings

Grants full administrative access to configure Private Messages settings and manage message/thread entities. This is a restricted access permission.

Write and view messages

Allows users to compose and send private messages, view their message threads, and reply to existing conversations.

Use messages actions

Allows users to perform bulk actions on message threads such as marking as read, marking as unread, and deleting threads.

Delete own messages

Allows users to delete (soft-delete) their own messages within threads. Deleted messages show a placeholder indicating deletion.

View deleted messages

Allows users to view the content of messages that have been marked as deleted by their authors.

Allow send messages to roles

Allows users to send private messages to all users with a specific role at once.

Allow to block another users

Allows users to block other users from sending them private messages and manage their blocked users list.

Hooks 2
hook_privatemsg_block_user

Invoked when a user blocks another user. Allows modules to react to user blocking.

hook_privatemsg_unblock_user

Invoked when a user unblocks another user. Allows modules to react to user unblocking.

Drush Commands 1
drush privatemsg:1to2

Migrates private message data from the 1.x version of the module to the 2.x entity-based structure. Reads from legacy pm_message_old and pm_index_old tables and creates new message and thread entities.

Troubleshooting 5
Users cannot send messages to each other

Check that both users have roles enabled in 'Allow send private messages for these roles' setting, both users have messaging enabled in their profile (Edit profile > Private Messages > Enable private messages), and neither user has blocked the other.

Email notifications are not being sent

Verify that the recipient has 'Receive email notification for incoming private messages' enabled in their profile settings and that Drupal's mail system is properly configured.

Deleted messages are not being removed from the database

Ensure cron is running regularly. Deleted messages are permanently removed by the cron job after the configured number of days in 'Remove deleted messages from DB after (days)' setting.

Cannot block certain users

The user may have a role configured in 'Users cannot block another users with these roles'. Administrators typically configure important roles like support staff as unblockable.

Private Messages menu item shows incorrect unread count

The count uses lazy building with no caching. If issues persist, clear all caches and verify the database tables pm_thread_history and pm_index are properly populated.

Security Notes 5
  • The 'administer privatemsg' permission grants full access to all messages and settings - assign only to trusted administrators.
  • User blocking only prevents message sending; it does not hide existing messages from either party.
  • Email notifications include a link to the message thread - ensure your site uses HTTPS to protect these links.
  • The 'View deleted messages' permission allows seeing message content even after deletion - consider carefully who receives this permission.
  • Messages use Drupal's text format system - ensure appropriate formats are available to prevent XSS attacks.