Display number of pending messages and friend request on the user menu I'm using Privatemsg &amp; User Relationships and the built-in user menu as a sidebar block. What I want is to display the unread messages count and the pending friends requests beside the links "My messages" &amp; "My friends".

Any ideas of how can I do this? Thanks in advance.

Mock-up:
This will return the unread private messages in Drupal 7.

&lt;?php
global $user; privatemsg_unread_count($user);
?&gt;


Refer this for more discussion

This will return pending relationship request for the loggedin user.

&lt;?php
function _count_pending_relationships($account = NULL) {
  $counts = &amp;drupal_static(__FUNCTION__, array());
  if (!$account || $account-&gt;uid == 0) {
    global $user;
    $account = $user;
  }

  if (!isset($counts[$account-&gt;uid])) {
    $count = 0;
    $pending_relationships = user_relationships_load(array('requestee_id' =&gt; $account-&gt;uid, 'approved' =&gt; 0), array('count' =&gt; TRUE));
    if (!empty($pending_relationships)) {
      foreach($pending_relationships as $requester_uid =&gt; $relationship) {
        if($account-&gt;uid != $requester_uid) {
          $count++;
        }
      }
    }
    $counts[$account-&gt;uid] = $count;
  }

  return $counts[$account-&gt;uid];
}
?&gt;


Refer this for detail discussion.

You can create a block and create respective links with the functions shown above.