How can I assign an icon to users depending on their gender? I'd like comments on my website to look like this:



Every comment has to be preceded by an image, depending on the gender of the user who wrote the comment. Users can choose Male/Female as their gender when they register, so the icon can't be changed: it's only related to the gender. How can I achieve this?
Create a vocab as gender and add two taxonomies to it as male and female. To the gender vocab add image field and while creating the male and female taxonomy term add the respective images.

Now add the term reference file to user entity and keep it as stele list.

In your custom module hook_user_presave and get the value for the taxonomy field.when you know the selected taxonomy you can load the taxonomy to get the image field fid associated with it assign the fid to $user->picture.

Now everywhere image will load as per the gender selected.