PDA

View Full Version : How to use "or" in a template


smokin1337
10-11-2009, 04:51 PM
I want to use this statement but it's not working. Any ideas what i need to change to make it work ?

<if condition="$bbuserinfo['usergroupid'] != 1 || 3">

It works like this:

<if condition="$bbuserinfo['usergroupid'] != 1">

I am trying to make some content unviewable to those 2 usergroups. I figured a regular "or" statement would work but i guess not. Any help would be much appreciated. Thanks in advance !!

Shadab
10-11-2009, 04:54 PM
Try this:

<if condition="!in_array($bbuserinfo['usergroupid'], array(1, 3))">

smokin1337
10-11-2009, 06:26 PM
Works perfect thank you very much.

Shadab
10-14-2009, 03:37 PM
Works perfect thank you very much.
Not a problem. :)

James Birkett
10-14-2009, 06:22 PM
Going off your original syntax, I think it should be this way:
<if condition="$bbuserinfo['usergroupid'] != 1 || $bbuserinfo['usergroupid'] != 3">
In PHP, when using boolean operators, you have to re-declare your variable. You can't say "If $this = 1 OR 2" it has to be "if $this = 1 OR $this = 2"