How to print a custom user field in comment.tpl.php? I'm trying to print a custom user field (field_avatar) image as a replacement for the user picture. Why? user picture file directory would not accept tokens. This mean, I could run into a scenario where there are 100k files in a directory slowing the website!

From googling answers for hours, this is the best solution I've read.

In comment.tpl.php placed in my custom omega 4 subtheme, I added this code.

&lt;?php  print render(field_view_field('user', $user, 'field_avatar'));  ?&gt;


However, above code prints the default field_avatar picture! not field_avatar based on the comment ID? or UID of the author?

Please shed some wisdom smart ones!
I've got it working! I've used user_load($comment->uid) to load the author relationship.

I placed the code in a copy of comment.tpl.php in my sub theme.

&lt;?php print render(field_view_field('user',user_load($comment-&gt;uid), 'YOUR-CUSTOM-USER-FIELD'));?&gt;


Cheers and good luck!