1

I'm using Privatemsg module and I want to print simple "You have new message" and "You have no new messages" for given user how to do that?

0

Assuming you want to do this programmatically, or be able to easily customise it in a block, it can be done easily - I have not done this in 6, only 7 so some other steps may be necessary:

<?php /* check privatemsg for unread messages */ ?>
  <?php $unread = privatemsg_unread_count(); ?>

  <?php if($unread > 0)
  { ?>
    <a id="message_notify" href="/messages" title="<?php echo $unread; ?> new messages">
      <img src="/sites/all/themes/myTheme/images/envelope_green.png" style="display:inline-block; vertical-align:top; height:18px; margin-left:5px;">
    </a>
  <?php } else { ?>
    <a id="message_notify" href="/messages" title="no new messages">
      <img src="/sites/all/themes/myTheme/images/envelope_grey.png" style="display:inline-block; vertical-align:top; height:18px; margin-left:5px;">
    </a>
  <?php } ?>

This should work with any version of privatemsg but does require php be enabled - or in a custom block. adjust as desired - in my example I use two images of envelopes, one grey for no messages and one green for unread messages - that's just UI, and doesn't need to be there if desired.

  • This is exactly what I wanted, works like a charm thanks mate!!! – drupaluser May 21 '15 at 21:41
  • Btw do You know how to do same only with posts "You have unread posts or You have no unread posts"? – drupaluser May 21 '15 at 22:47
  • @drupaluser that depends how you are assigning 'posts' - what are using to define that value? nodes, flags, etc? – Geoff May 22 '15 at 1:28
  • New replies to forum threads that user started or commented in and then I'd like to link it to the list of all those threads, I've seen it on phpbb, would like something similar. – drupaluser May 22 '15 at 2:11
  • something like this to give You an idea blog.phpbb.com/wp-content/uploads/2014/02/notifications.png – drupaluser May 22 '15 at 13:59
1

The module automatically does that when a user logs in who has the message waiting. It DOES NOT print you have no new messages - because that is redundant. It did it that way when we use it on our site - Drupal 6 - have not enabled and used it however yet on Drupal 7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.