Secondary usergroup in "message_user_info"

In my message_user_info template I've inserted {$user.user_group_id} to show ID of primary usergroup. But now I want to show the secondary usergroup with the highest display styling priority: how could I do that?
 
I explain my needs.

My usergroups are inspired by military hierarchy (Soldier, Sergeant, Lieutenant, Captain, etc etc) and I use the promotion system to permit them to climb the hierarchy.

In my old vB4 forum, I put this in "postbit":

<img src="/styles/usergroup/{vb:raw post.usergroupid}.png" />

to show an image that represent the grade of the user, and it changes every time system promote the primary usergroup.

In XF this is not possible because the promotion system doesn't change the primary usergroup, but only the secondary group, and this code in “message_user_info”:

<img src="/styles/usergroup/{$user.user_group_id}.png" />

show an image that represent the primary usergroup: is there another way to view an image for secondary usergroup with highest priority?
 
You can use a condition structure like this where you check groups in order of priority:

Code:
<xen:if is="{xen:helper ismemberof, $user, 4}">
	HIGHEST IMAGE
<xen:elseif is="{xen:helper ismemberof, $user, 5}" />
	SECOND HIGHEST
<xen:elseif is="{xen:helper ismemberof, $user, 6}" />
	THIRD HIGHEST
<xen:else />
	LOWEST OR DEFAULT IF THEY AREN'T IN ANY OF THE GROUPS
</xen:if>
 
Top Bottom