Search code examples
syntaxconditional-statementsvbulletinusergroups

vBulletin 4 - How do I branch a conditional based on usergroup?


I'm trying to replace a person's user name with their user title if they're a member of a certain user group. I've tried both

<vb:if condition="is_member_of($vbulletin->userinfo, 14)">

and

<vb:if condition="is_member_of($bbuserinfo, 14)">

and neither seem to be working.

This is what I have.

<a class="username {vb:raw memberinfo.online} popupctrl" href="{vb:link member, {vb:raw memberinfo}}" title="{vb:rawphrase {vb:raw memberinfo['onlinestatusphrase']}, {vb:raw memberinfo.username}}">
    <vb:if condition="is_member_of($vbulletin->userinfo, 14)">
    <!-- <vb:if condition="is_member_of($bbuserinfo, 14)"> -->
        <vb:if condition="$memberinfo['musername']">{vb:raw post.usertitle}
        <vb:else />{vb:raw post.usertitle}
        </vb:if>
    <vb:else /><strong>
        <vb:if condition="$memberinfo['musername']">{vb:raw memberinfo.musername}
        <vb:else />{vb:raw memberinfo.username}
        </vb:if></strong>
    </vb:if>
</a>

When I try to use this template, this is what happens and this is what it normally looks like with the code below.

The code I'm replacing is

<a class="username {vb:raw memberinfo.online} popupctrl" href="{vb:link member, {vb:raw memberinfo}}" title="{vb:rawphrase {vb:raw memberinfo['onlinestatusphrase']}, {vb:raw memberinfo.username}}">
<strong><vb:if condition="$memberinfo['musername']">{vb:raw memberinfo.musername}<vb:else />{vb:raw memberinfo.username}</vb:if></strong></a>

Solution

  • $vbulletin->userinfo and $bbuserinfo grab the user viewing the page. What you want is to grab the user whose post you are iterating over. If you look at the context of your code, all of the vBulletin variables stem from $memberinfo. That's the current poster, and the variable we want.

    Try:

    <vb:if condition="is_member_of($memberinfo, 14)">