In privatemsg_view(), the participants are being added to the $content array using #markup and the theme() function:

$content['participants'] = array(
  '#markup' => theme('privatemsg_recipients', array('thread' => $thread)),
  '#weight' => -5
);

As well, the messages are also being added in #markup using the theme() function:

$content['messages'][$pmid] = array(
  '#markup' => theme('privatemsg_view', array('message' => $message)),
);

Unfortunately, this means that the participants and messages cannot be altered after this point as they have been rendered. Switching to a render array lets the objects be altered by other modules before they are rendered.

Recipients:

$content['participants'] = array(
  '#theme' => 'privatemsg_recipients',
  '#thread' => $thread,
  '#weight' => -5
);

Messages:

$content['messages'][$pmid] = array(
  '#theme' => 'privatemsg_view',
  '#message' => $message,
);

I've just run into the issue where I needed the timestamp of the last private message for a script I'm writing, but I wasn't able to get it as the messages were already rendered into HTML. By making this switch, I was able to get the timestamp in hook_privatemsg_view_alter().

CommentFileSizeAuthor
#1 content-themed-too-early-1736446-1.patch721 bytesJaypan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jaypan’s picture

Attached is a patch to fix this.

ptmkenny’s picture

Category: task » bug
Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, content-themed-too-early-1736446-1.patch, failed testing.

ptmkenny’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, content-themed-too-early-1736446-1.patch, failed testing.

Jaypan’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)

This issue is so old, and I ended up writing my own private message module and don't even use the privatemsg module anymore, so I'm closing it.