This question has been answered by donshakespeare. See the first response.
[[!UserMessages]]
<?php
/* UserMessages snippet */
/* initialize variables */
$userId = $modx->user->get('id');
$output = '';
/* Get the current user's messages */
$messages = $modx->getCollection('modUserMessage', array('recipient' => $userId));
/* Loop through messages (if any) and add them to the output */
if (! empty ($messages)) {
$output = '<h3>You have Recieved these messages</h3>';
foreach ($messages as $message) {
$fields = $message->toArray();
/* replace sender ID with username */
if (isset($fields['sender'])) {
$sender = $modx->getObject('modUser', (integer) $fields['sender']);
if ($sender) {
$fields['sender'] = $sender->get('username');
}
}
$output .= $modx->getChunk('messageTpl', $fields);
}
} else {
$output = '<h3>You have no messages</h3>';
}
return $output;
<p>Subject: [[+subject]]</p> <p>Sender: [[+sender]]</p> <p>Message: [[+message]]</p>
type (string)
subject (string)
message (string)
sender (integer)
recipient (integer)
private (integer)
date_sent (datetime)
read (integer)