How to show the user badges in my tpl.php file?
The first thing that you need to do is add the php tag to the code:

&lt;?
if (module_exists('user_badges')) {
 print user_badges_for_uid($uid);
}
?&gt;


But for to that this code works you need to pass the uid = User Id

This code should do the job:

&lt;?
// Getting the actual user.
global $user;

if (module_exists('user_badges')) {
 print user_badges_for_uid($user-&gt;uid);
}
?&gt;