A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
8

I really don't know why you don't like the answer by Rene. Let me show a more detailed example. You have to replace YOURMODULE with name of your module or theme. /** * Implements hook_privatemsg_message_view_alter(). * The & for param $vars is important: we pass it by reference. */ function YOURMODULE_privatemsg_message_view_alter(&$vars) { // ...


4

Note: this is answer for Drupal 7. As Letharion said, you can use hook_mail_alter() but you should detect somehow is this a welcome message from admin or not. I suggest Context module for this task, but you really can just compare a subject of message in this hook. Update First I suggested to use Context module, but it is no so simple to set context ...


4

For a variable to be available in the scope of a function, it needs to have been initialised (or it needs to have been initialised in the global scope and imported into the local function using global). At the moment there's nothing declaring or passing the $vars variable in...it hasn't been initialised, thus you get the warning. You're passing a variable ...


4

That's (arguably) non-standard, so you'll need a where. For example, $query = db_select('foo'); $query->where(':val IN ({table1}.col1, {table2}.col2)', array(':val' => $user->uid)); will get you SELECT FROM {foo} foo WHERE (:val IN ({table1}.col1, {table2}.col2)) (with :val replaced by $user->uid).


4

I don't think you can use the Rules module directly for this, because the only action that is provided by Privatemsg is called when a message has been sent. Therefore, I suggest you write an easy piece of code. When a user hasn't set a profile picture yet, the field is empty or displays the default picture if you picked one in your configuration. In both ...


3

In this case, the problem is that privatemsg_get_link() uses array() as default value for $account, but then uses the following code. if ($account == NULL) { global $user; $account = $user; } The function should use NULL as default value for $account, in the same way user_access() does. function user_access($string, $account = NULL) { global ...


3

The parameters given to hook_privatemsg_message_validate() are $message, and $form which has a default value of FALSE. $vars is not a parameter passed to the function, nor is a local variable defined from the function. As consequence of this, the value of $vars is NULL. When you try accessing $vars['message']->author->uid, PHP would give you two ...


3

that's a great idea, I would love to see that too. Wouldn't it be easier replacing the default page with a view? Then you can style it any way you want. The "checkboxes" and actions could be done with VBO.


3

Using hook_mail_alter you can stop the sending from happening with $message['send'] = FALSE. Unfortunately this gives no direct way of knowing that the mail is "the first mail", or "from uid 1". I believe that would need to be a match directly against the body text. The calling $module is however available, so you can limit the manipulation that way.


3

There are two ways to do this. The pm_block_user module has settings that allow for role-based configurations for who is allowed to write whom. However, it is only possible to add positive rules. Meaning, you wold need to add all your users into a normal role that the system user is not part of and then allow users of that role to write users of that role. ...


3

(I haven't used privatemsg) ... but sure it's doable because of a new feature in D7: Instead of attachments, private messages are fieldable and any number and combination of fields can be added to them. So what you do is code up a custom module that defines a custom "sent_by_sitename" field that is a text field_type. Then in your presave hook you would ...


3

There is a privatemsg_unread_count() function in Drupal 7. If that doesn't work in Drupal 6, check the module file for the name of the function.


3

Privatemsg 6.x-2.x has a Limits submodule built in, either use that version or use try out the separate project for 6.x-1.x, you will have to find out yourself it is working well enough for you.


3

Have you tried String Overrides module? Here is a quote about it (from the module's project page): ... a quick and easy way to replace any text on the site. Features: Easily replace anything that's passed through t() Locale support, allowing you to override strings in any language Ability to import/export *.po files, for easy migration ...


3

This is off the top of my head with some parts but I think this is the way you would do it. print theme('image_style', array('path' => $message->author->picture->uri, 'style_name' => '{image-style}')); With {image-style} replaced with image style that you want like thumbnail. If this doesn't work I will take a second look.


3

Add these two date formats (in admin/config/regional/date-time/formats): M d H:i Y M d H:i After that choose above created date formats (in admin/config/regional/date-time) in Privatemsg: Current year & Privatemsg: Other years respectively.


3

By default, giving a role the permission to delete messages will not delete the message for the other user. I just tested this and it works as you require. As for only allowing messages between certain users, you can prepopulate the "To" field with /messages/new/[nid]. So on the user page or in views or whatever, you can create this link using tokens or ...


3

In general with Drupal you want to avoid directly querying the database if you didn't create the tables yourself. Instead try to use functions provided by core or the module to get the data for you. The table structures are often complicated and may change without notice, but the functions for accessing those tables generally adapt to the changes (this is ...


3

Any other ways I can get it to work, outside of hacking the module? There is no way to alter a module from another php file / module unless it provides a hook, luckily here they did. I must be blind, right above it (line 1098), it says in the comments: * @see hook_query_privatemsg_messages_alter() I found the doc hook_query_privatemsg_messages_alter. ...


2

The following code does it for me: function MYMODULE_form_pm_block_user_list_alter(&$form, &$form_state, $form_id) { unset($form['new']); } This should help if you didn't know about it. hook_form_FORM_ID_alter(); Also there's the more generic hook_form_alter().


2

Private Message displays the user picture via a theme('user_picture') so I'd just copy the user-picture.tpl.php template out of the system user module directory and into your theme's and modify it to display your field instead of the default. You may want to put additional logic in there so that it doesn't do this everywhere but that's up to you.


2

I've just implemented the Privatemsg Panels plugin with the D7 Patch through the pm_existing_pages plugin and it's working quite well! Here's how it all goes down for Drupal 7: Grab the master branch of the privatemsg_panels module and upload to your modules directory Patch Manager is super handy - install it and run the panels_privatemsg7.patch file to ...


2

One way you could do this (which is what I do on a couple sites), is to implement hook_privatemsg_message_insert() in a custom module. Turn off the privatemsg module emails or any rules-generated emails, and instead write a custom bit of code that sends the private message. In my case, I needed to do a few other customizations, but at its simplest, you can ...


2

Hooks are a way of extending contrib modules without having to hack them. It's saying when this function runs in the the contrib module run all other functions that match the hook signature more or less (there would be a more accurate and concise explenation on drupal.org somwehere). You need to add the code to you custom .module file and replace the word ...


2

Open privatemsg.module in hook_menu search for $items['messages/user-name-autocomplete'] this particular menu item defines that auto complete path. Search for privatemsg_user_name_autocomplete function where the output defines. Edit this function. Thats all. Also Create a patch if youre familiar with patching, so that others c


2

This code is used to get the list of all the messages in the inbox. global $user; $query = _privatemsg_assemble_query('list', $user, 'inbox'); $total_count = db_result(db_query($query['count'])); echo $total_count;


2

Try this code in block, if you don't want to implement any hook in custom module. $node = menu_get_object(); if ($node->uid != 0) { module_load_include('pages.inc','privatemsg'); $recipients = $node->uid; print "<div>Contact " . $node->name ." about this post.</div>"; $subject = $node->title ." question."; $form = ...


2

I guess the private message form sets the title directly. A simple way round it might be to cache the current title before you render the form, then set it back again afterwards: $stored_title = drupal_set_title(); print drupal_render(drupal_get_form('privatemsg_new', $recipients, $subject)); drupal_set_title($stored_title);


2

From the page that you linked to: // Replace 'inbox' with 'sent' to display sent messages or 'list' to display all messages. $query = _privatemsg_assemble_query('list', $user, 'inbox'); Note that the privatemsg_filter module needs to be enabled for that to work.


2

You will need to create a custom module to use that hook it will allow you to run custom validation on top of the standard validation done by private msg. A hook allows you to add functionality to a module without having to hack the module causing issues when the original module needs to be updated. When a module makes a hook available it allows other ...


Only top voted, non community-wiki answers of a minimum length are eligible