MyBB Hacks

Full Version: PHP in Templates / Complex Templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Code:
<if $mybb->user['usergroup'] == 3 || $mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 6 then>
something
</if>

The above code works but when I use not equal to it does not work.

Code:
<if $mybb->user['usergroup'] != 3 || $mybb->user['usergroup'] != 4 || $mybb->user['usergroup'] != 6 then>
something
</if>

The above does not work.

But again

Code:
<if $mybb->user['usergroup'] != 3 then>
something
</if>


The above code works..

Is it something wrong with the code or a bug or something?

(10-09-2010 12:37 AM)techu Wrote: [ -> ]The above code works but when I use not equal to it does not work.

Code:
<if $mybb->user['usergroup'] != 3 || $mybb->user['usergroup'] != 4 || $mybb->user['usergroup'] != 6 then>
something
</if>

The above does not work.

Obviously, when can that statement ever be false?

Think about it:

PHP Code:
if($x != 1 || $x != 2)

There is no value of $x which can make the above statement false.

/\oh ok.


basically what I was trying to do is that I want to show some html only for normal user, I dont want that part of html to admin, mod and super mod so how can I do that?
You're asking for two different things.

(10-09-2010 12:24 PM)techu Wrote: [ -> ]I want to show some html only for normal user

Code:
<if $mybb->user['usergroup'] == 2 then>
...
</if>



(10-09-2010 12:24 PM)techu Wrote: [ -> ]I dont want that part of html to admin, mod and super mod so how can I do that?

Code:
<if $mybb->user['usergroup'] != 3 && $mybb->user['usergroup'] != 4 && $mybb->user['usergroup'] != 6 then>
...
</if>

(you need to use AND, not OR)
Or

Code:
<if !in_array($mybb->user['usergroup'], array(3,4,6)) then>
...
</if>

spot on...
Thanks Smile
Hi, I would like to be able to unlock some forums/extra privileges etc on my site based on which FORUM a user has started a thread in. Is there a php in templates snippet I could put in the templates for that? I would like it to be automatic and as the user promotion system does not support creating threads as a criteria for promotion I don't really want to use GIDs as that would mean I have to move the users to a specific group manually.

Can anyone help?
Probably try something like this - note, it won't do a promotion as you've said, PHP in Templates is only really good at manipulating what's displayed:

PHP Code:
<?php
if($mybb->user['uid'])
$has_made_thread_in_forum = $db->fetch_array($db->simple_select('threads', 'tid', 'uid='.$mybb->user['uid'].' AND fid='.$foruminfo['fid'], array('limit' => 1)));

if($has_made_thread_in_forum) ...
?>

Thank you Zinga - I shall go and try that Smile
have anyone encountered this? the if conditions are ignored in Internet Explorer. Can anyone please check and update here?
That shouldn't even be possible as this doesn't have any behavioural relationship with browsers.  This is purely a server side plugin.
Unless, of course, you're explicitly causing something to break on the browser side, or you're explicitly doing something browser dependent.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Reference URL's