Question: How can I display using a normal template, how many private messages the logged in member has?
Answer: Use the following code snippet
{if logged_in}
<?php
global $SESS;
$pmcount = $SESS->userdata['private_messages'];
if ($pmcount == 1) {
echo 'You have a new private message!';
} elseif ($pmcount > 0) {
echo 'You have '.$pmcount.' new private messages!';
}
?>
{/if}
A modification by lebisol:
This logic of counter starting from 1 was a bit confusing since there is no “unread” message counter.
Perhaps someone can benifit from this code snip:
<li><a href="{homepage}/forums/member/messages/view_folder/1/">Private Messages</a>
<?php
global $SESS;
$pmcount = $SESS->userdata['private_messages'];
if ($pmcount > 0) {
echo '['.$pmcount.']';
}
else {
echo'[0]';
}
?>
</li>
Category:Members
Category:Templates
