This is the code from my site which is working, though it may be modified, but it should help you figure out what the problem is.
Code:
<h2>{#PLIGG_Visual_User_Profile_Viewing_Friends_2a#}</h2>
{if $friends}
<table>
{if check_for_enabled_module('simple_messaging',0.6) && $is_friend}
<th style="width:250px;text-align:left;">{#PLIGG_Visual_User_Profile_Username#}</th>
<th style="width:60px;text-align:left;">{#PLIGG_Visual_User_Profile_Message#}</th>
{/if}
{foreach from=$friends item=myfriend}
{php}
$this->_vars['friend_avatar'] = get_avatar('small', $this->_vars['myfriend']['user_avatar_source'], $this->_vars['myfriend']['user_login'], $this->_vars['myfriend']['user_email']);
$this->_vars['profileURL'] = getmyurl('user2', $this->_vars['myfriend']['user_login'], 'profile');
$this->_vars['removeURL'] = getmyurl('user_add_remove', $this->_vars['myfriend']['user_login'], 'removefriend');
{/php}
<tr>
<td><img src="{$friend_avatar}" align="absmiddle" /> <a href="{$profileURL}">{$myfriend.user_login}</a></td>
{if check_for_enabled_module('simple_messaging',0.6) && $is_friend}<td><a href="{$my_pligg_base}/module.php?module=simple_messaging&view=compose&to={$myfriend.user_login}&return={$templatelite.server.REQUEST_URI|urlencode}"><img src="{$my_pligg_base}/modules/simple_messaging/images/reply.png" border="0" /></a></td>{/if}
</tr>
{/foreach}
</table>
{else}
<br /><br />
<h2 style="text-align:center;"><span style="text-transform:capitalize;">{$user_username}</span> {#PLIGG_Visual_User_Profile_No_Friends_2#}</h2>
{/if}