By default, Privatemsg orders messages in a thread from oldest to newest. This means that users have to scroll down in a thread to see the newest message. This can be annoying especially if you have a long thread.
You can change the order to display messages from newest to oldest by writing a custom module. It's very easy and you can have it up and running in just a few minutes. Here are the steps:
1. Create a directory called privatemsgsort
2. Create a file within that directory called 'privatemsgsort.module'.
3. Put the following code into this privatemsgsort.module:
<?php
function privatemsgsort_privatemsg_sql_messages_alter(&$fragments, $threads, $account = NULL, $load_all = FALSE) {
$fragments['order_by'] = array();
$fragments['order_by'][] = 'pm.timestamp DESC';
$fragments['order_by'][] = 'pmi.mid DESC';
}
function privatemsgsort_privatemsg_sql_load_alter(&$fragments, $pmids, $account = NULL) {
$fragments['order_by'] = array();
$fragments['order_by'][] = 'pm.timestamp DESC';
$fragments['order_by'][] = 'pmi.mid DESC';
}
4. Create another file in that same directory called 'privatemsgsort.info'. This is the file that will make your module visible in Drupal module settings.
5. Put something like this into that file:
name = Private Message Sort
description = Allows you to sort private messages descending.
core = 6.x
package = Custom
php = 5.1
6. Upload this directory (unless you were already doing this on the server) to your /sites/all/modules directory. For organization sake, you could put this directory inside a 'custom' directory but that's up to you.
7. Go to your modules page /admin/build/modules/list and look for the 'Private Message Sort' module. Tada! The new messages in a thread should now be appearing on top.
This is the first time that I have ever created a page like this so please feel free to let me know if there is a better way to do this.