Last updated February 2, 2010. Created by Feonyx on February 2, 2010.
Log in to edit this page.
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:
<?php
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!
Comments
The above thing is not working.
Hey i tried to implement the above changes. I went to the privatemsg.api.php folder and pasted the above code as-
function hook_privatemsg_sql_participants_alter(&$fragment, $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;
}
But i am still getting the same view of participants.
Any solutions??
How about creating you module
How about creating you module called for example "your_module" and then
function your_module_privatemsg_sql_participants_alter(&$fragment, $thread_id) {
...
}
NOP Dont work
NOP Dont work
Did NOt Work
Hey i made my custom module and used the above code for finishing the task. But still it did not work out for me.
Don´t work. If you reply to a
Don´t work. If you reply to a pm the recipient will always be the author of the first message of that thread also if the author of the first message wants to reply. In that case the author of the first message of that thread would send a message to himself.
It might be useful if we also
It might be useful if we also can do this:
Send each users a separate message thread when there are multiple users in the list. So in each thread there are only two participants: Sender and receiver.
Here is how I did it in the ugly way..(Please don't use it on production site since it's not been tested enough)
<?php/**
* Implementation of hook_privatemsg_message_presave_alter
*/
function YOUR_MODULE_privatemsg_message_presave_alter(&$message) {
if(is_array($message['recipients']) && count($message['recipients']) > 1) {
// We only allow last recipient to be pass to the original workflow. For all other messages we send them through a new recursive function call
$message_recursive = $message;
$message['recipients'] = array(array_pop($message_recursive['recipients']));
_privatemsg_send($message_recursive);
}
}
?>
If there is any other way to do this please reply.
佛陀正法网
Drupaler China