MyBB Community Forums

Full Version: multiple variables in php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to make it so staff miniprofiles appear differently than a regular user's miniprofile. I have the plug in that allows me to use a kind of short hand version of php in my templates. If you're unsure what that is, you can view it here: http://mybbhacks.zingaburga.com/showthread.php?tid=260


Anyway, when I set it to affect just one of the staff groups, it works great, but when I try to set it to multiple groups, that's when problems arise.

What I've got looks something of this sort...

<!-- GUEST VS. MEMBER DECIDER -->
<if $post['uid'] then>
  <if $post['usergroup'] == '3 or 8' then><!-- STAFF POST BIT -->

stuff

  <elseif $post['usergroup'] != '3' then><!-- REGULAR POST BIT //-->

stuff

  <elseif $post['uid']== '4' then><!-- SPECIAL PROFILE WITH CUSTOM DESIGN. NO ISSUE GETTING THIS TO WORK -->

more stuff

</if>
<else><!-- GUEST POST BIT -->
even more stuff
</if>


Now, the problem I'm currently am having is no matter what I try, no matter what I read on and try to implement, it either:
- will ONLY work for the first staff group listed (here, usergroup 3), and every other group listed as well as any not listed at all just displays as a normal user
- OR it will work for ALL groups, staff and user alike, indiscriminately but for the guest accounts, which will display as I have set them too.


Any ideas?
I'm not sure how this plugin is parsing the PHP, but I'm sure your problem is with

 <if $post['usergroup'] == '3 or 8' then>

This would be checking the usergroup for the literal string '3 or 8'. I'd give you an examle of something that might work but typing words on this phone is dreadful, let alone code.
You would need to use an array:

<if in_array($post['usergroup'], array(3,8)) then>
Text
</if>

or

<if $post['usergroup'] == 3 || $post['usergroup'] == 8 then><!-- STAFF POST BIT -->
</if>

Something like that (not tested)
that worked wonderfully, thank you!