Announcement

Collapse
No announcement yet.

Conditional to show info to certain usergroups

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Conditional to show info to certain usergroups

    I'm looking for the conditional that allows to show information only to certain usergroups, lets say ID's 5,6,7,8, etc.
    I found the one for VB4 but it doesn't work on vB5, thank you for your help.

  • #2
    I would use something like this in the templates:

    Code:
    <vb:if condition="$user['usergroupid']== 5">
    {vb:phrase your_custom_phrase}
    <vb:else />
    {vb:phrase your_alternate_custom_phrase}
    </vb:if>
    You'd have to create the two phrases in the language manager
    your_custom_phrase
    your_alternate_custom_phrase
    What's brewing in Poland? Find out on www.Browar.biz (in Polish)
    PL: Modyfikacje vB: www.pub.net.pl

    Comment


    • #3
      Originally posted by Turtullo View Post
      I would use something like this in the templates:

      Code:
      <vb:if condition="$user['usergroupid']== 5">
      {vb:phrase your_custom_phrase}
      <vb:else />
      {vb:phrase your_alternate_custom_phrase}
      </vb:if>
      You'd have to create the two phrases in the language manager
      your_custom_phrase
      your_alternate_custom_phrase
      Seems to work for 1 usergroup but can't add more ID's, is it possible to add mulitple usergroups?
      thank you

      Edit:
      I found it,
      Code:
      <vb:if condition="in_array($user['usergroupid'], array(76,40,3))"> code in here </vb:if>
      Thank you for your help!

      Comment


      • #4
        in_array() should work. It is an allowed PHP Function. There is also the is_member_of function. I think the format is still is_member_of($user, 76, 40,3)

        However, you're going to run into caching issues so the first person to view the condition will trigger it. Everyone else will see the same thing. To work around this, you will need to take a minor performance hit and turn on BBCode caching per usergroup in the AdminCP under Settings -> Options -> BB Code Settings. View the AdminCP Help on this option for more information.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API

        Comment


        • #5
          Originally posted by Wayne Luke View Post
          in_array() should work. It is an allowed PHP Function. There is also the is_member_of function. I think the format is still is_member_of($user, 76, 40,3)

          However, you're going to run into caching issues so the first person to view the condition will trigger it. Everyone else will see the same thing. To work around this, you will need to take a minor performance hit and turn on BBCode caching per usergroup in the AdminCP under Settings -> Options -> BB Code Settings. View the AdminCP Help on this option for more information.
          Thanks, does is_member_of look for both primary and secondary groups?

          Comment


          • #6
            It should test both the usergroupid (primary) and membergroupids (secondary) fields.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API

            Comment

            Related Topics

            Collapse

            Working...
            X