MyBB Community Forums

Full Version: Add Conditions in Templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I wanted to know how to add conditions in templates ...

Example

Say I have a Menu which I only want to display to a particular User Group ,

Or say a Signature of a Particular Usergroup should also include a custom text in addition of their signature...


Please dont give me links to Plugins which can do the above examples, I want to know how to add these custom conditions in Templates by my self , if there is a Hook or something to be added ill do it...

I tried the "<?php if = " tags in templates but it does not check the condition at all , is there a way to do it?
Install this plugin: http://community.mybb.com/thread-31860.html

After installing, you'll be able to use PHP in templates like this;
<if $mybb->user['usergroup'] == 3 then>
// show to that usergroup.
</if>
Yep, and support is best for the plugin at MyBB Hacks - home of that plugin and other great ones (like Xthreads)!
I second this plugin. I use it all the time and I've had no issues.
(2012-04-28, 06:10 PM)Yaldaram Wrote: [ -> ]Install this plugin: http://community.mybb.com/thread-31860.html

After installing, you'll be able to use PHP in templates like this;
<if $mybb->user['usergroup'] == 3 then>
// show to that usergroup.
</if>

Thanks...It worked like a charm!!
(2012-04-28, 06:10 PM)Yaldaram Wrote: [ -> ]Install this plugin: http://community.mybb.com/thread-31860.html

After installing, you'll be able to use PHP in templates like this;
<if $mybb->user['usergroup'] == 3 then>
// show to that usergroup.
</if>

How would I make that available to multiple user groups?

Like, instead of just 3, how could I make it for 3, 5 and 7?
<if $mybb->user['usergroup'] != 3 && $mybb->user['usergroup'] != 5 && $mybb->user['usergroup'] != 7 then>
// show to that usergroup.
</if>

or:

<if !in_array($mybb->user['usergroup'], array(3,5,7)) then>
// show to that usergroup.
</if>
Is this plugin secure?
(2012-04-29, 03:45 PM)mattias Wrote: [ -> ]Is this plugin secure?

Of course it is Smile Even it's better to have so you can prevent some spam of bots if you have some idea etc etc.
Cool, I will check it out Smile
Pages: 1 2