HowTo: Remove recipients of a Privatemsg

Last updated on
30 April 2025

This page explains how to remove all the recipients of the Privatemsg thread so that only the sender is visible in the participants.

I wanted to be able to send messages to multiple people without all those people knowing who else I sent the message to (exactly how BCC works in email).

Berdir the modules maintainer kindly sent along this code:

function yourmodule_privatemsg_sql_participants_alter(&$fragments, $thread_id) {
  global $user;

  // Join table that contains author information.
  $fragments['inner_join'][]  = 'INNER JOIN {pm_message} pm ON (pm.mid = pmi.mid)';

  // Only include the author of the first message of that thread and
  // the current user (needed for permission checks).
  $fragments['where'][] = '(pmi.uid = pm.author AND pmi.mid = pmi.thread_id) OR pmi.uid = %d';
  $fragments['query_args']['where'][] = $user->uid;
}

Which accomplished this perfectly. Thanks Berdir and thanks for this awesome module!

Help improve this page

Page status: Not set

You can: