PDA

View Full Version : If conditional help


Jolten
08-29-2004, 12:56 AM
Hi,

I'm tryign to write an if conditional in the Member info template which will display information to a user if it's thier profile page and to all admins.

I can work out the user conditional with this:

<if condition="$bbuserinfo[userid] == $userinfo[userid]">
Stuff
</if>

But I can't figure out how to add the condistion that if the browser is an admin they see the information as well.

I know I can use
<if condition="$bbuserinfo[usergroup] == 6">
Stuff
</if>

To display to admins.
But how do I get both conditionals to work for the same information. Currently admins get shut out becasue they don't meet the first condition or users get shut out because they don't meet the second condition.

Any help would be greatly appreciate.

Thanks.

defi
08-29-2004, 04:08 AM
Try...

<if condition="!is_member_of($bbuserinfo, 2) AND !is_member_of($bbuserinfo, 6) ">
<!-- Content :) -->
<!-- /Content -->
</if>

replace the italicized numbers with the usergroup id('s)

Jolten
08-29-2004, 04:57 AM
Thanks for the suggestions Jonathan.
Sorry, that won't work.

(yes I caught the typo in "condition" too)

What I want is to display information to $bbuserinfo[userid] == $userinfo[userid] and $bbuserinfo[usergroup] == 6 only.

The statement you've written appears like it would only show information if a user was a member of usergroup 2 and usergroup 6. I don't have any admins that are also in the registered users usergroup. In addition I have users that aren't in usergroup 2 and I need the information to only display to the single user, not all members of a usergroup. <if condition="$bbuserinfo[userid] == $userinfo[userid]"> works for the single users I just need to add the ability for admins to see this too.

Since my super admins are users 1 and 2 I can set this:
<if condition="($bbuserinfo[userid] == $userinfo[userid]) or ($bbuserinfo[userid] < 3)">
And it works. I just can't seem to set the admin usergroup and make it work.

At any rate, it's not working.

Anyone with any other suggestions?

defi
08-29-2004, 05:50 AM
What typo? I see no typo!? :p (Thanks for the catch)

You need to adjust the numbers I gave you and it'll work. You can add more also to that by just adding more AND's... I don't see why this wouldn't work.

Anyways, you should ask this over at vb.org

Jolten
08-29-2004, 05:56 AM
It doesn't work Jonathan. And again... I don't want to call usergroups other than the admin usergroup. I want to use a single userid and the admin usergroup. In any case it would need to be OR instead of AND because no one is going to be a member of both usergroups.

I've got it patched with <if condition="($bbuserinfo[userid] == $userinfo[userid]) or ($bbuserinfo[userid] < 3)"> for now. But if anyone knows how to replace $bbuserinfo[userid] < 3 with $bbuserinfo[usergroup] == 6, I'd appreciate it.

House_of_Crazed
08-29-2004, 07:15 AM
That should work, actually.

Let me go and look in my code and see if I can supply you with the necessary code.

HoC

House_of_Crazed
08-29-2004, 07:23 AM
Yep, why are you using is_member_of ??

Try this

<if condition="$bbuserinfo['usergroupid'] == '6'"> your code here </if>

HoC

defi
08-29-2004, 02:06 PM
Alright well it worked for my needs at my boards, so okay. You're still better off at vb.org

Jolten
08-29-2004, 05:26 PM
It's a template mod. It doesn't belong at vb.org.

And yeah $bbuserinfo[usergroup]== 6 does work by itself. But
<if condition="($bbuserinfo[userid] == $userinfo[userid]) or ($bbuserinfo[usergroup] == 6)">Stuff</if> won't work when they are in the same conditional.

Jolten
09-04-2004, 06:32 PM
I got it sorted. I had a couple characters missing.

<if condition="($bbuserinfo[userid] == $userinfo[userid]) || ($bbuserinfo[usergroupid] == 6)">Stuff</if>

Works

yj_enquirer
08-25-2005, 07:16 AM
I am sorry for digging up an old thread but what I would like some help with is similar to what is being mentioned in this thread.

I am trying to do a conditional IF loop.

Something like:

if ($bbuserinfo[usergroupid]!=6) or ($bbuserinfo[usergroupid]!=10)
{
print_no_permission();
}
else
{
stuff
}


however upon writing that code I get an error..

Parse error: parse error, unexpected T_LOGICAL_OR

Can anyone suggest a work-around please?

Thank-you

Marco van Herwaarden
08-25-2005, 07:23 AM
2 Errors: missing parenthesis & if combining NOT conditions you should use AND (using OR would always be true):
if (($bbuserinfo[usergroupid]!=6) AND ($bbuserinfo[usergroupid]!=10))

or best:
if ($bbuserinfo['usergroupid']!=6 AND $bbuserinfo['usergroupid']!=10)

yj_enquirer
08-25-2005, 07:44 AM
You are a start Macro.. Many thanks for your help. Yep, your suggestion (best one) worked and I am a happy bunny!