I need a feature for my website, I want that users can send pre-filled messages to others users.

Like in an user's profile page, they just have to click on a button and then, the pre-filled message is sent.

I'm using PrivateMsg module, I don't know if this module could do the job

(By the way I'm new to Drupal).

Thanks for your help !

1 Answer 1


You may implement this: hook_privatemsg_message_presave_alter.

Change the message before it is stored.

The $message variable contains the message's body (as well as much more parameters) ready to be edited. Note that you can include html tags in your message. Here is a code sample:

 * Implements hook_privatemsg_message_presave_alter().
 * Change the message before it is stored.
function my_module_privatemsg_message_presave_alter(&$message) {
  // dsm($message); print out the $message contents
  $name = $message->recipients['user_1']->name; // use foreach for many recipients
  $message->body = "<i>Dear $user</i>,\n <strong>you rock!</strong>";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.