Alright, I've changed the hook to showgroups_user and also have added the if condition into the foreach loop. The avatars changed according to the user now, along with the username and ID. Thanks.
However, if I change it in my UserCP, showgroups.php shows the old avatar still. Why is this happening, considering as far as I know, the forum uses the filesystem and/or DB?
EDIT: Also, the usernames seem to have vanished; only avatar is visible now. Tried reverting template, but that didn't work.