MyBB Community Forums

Full Version: Code to display a specific thing to a specific group
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi to all,
I wanted to know the code to display a specific thing to a specific group. I saw this thing in many plugins, for example in the plugin "My Advertisements". I need this code because i wanted to add banner adsense to postbit, but display only for the guest.
Sorry for my bad english Shy
You can use Template Conditionals plugin if you want to put the code in templates. http://mybbhacks.zingaburga.com/showthread.php?tid=464
Example code:
<if $mybb->user['uid'] == 0 then>
something only for guests
</if>

If you want to put the code in plugin, use similar condition.
if ($mybb->user['uid'] == 0)
{
    $banner = bannercodeforguestshere;
}
(2013-05-18, 10:01 PM)Destroy666 Wrote: [ -> ]You can use Template Conditionals plugin. http://mybbhacks.zingaburga.com/showthread.php?tid=464
Example code:
<if $mybb->user['uid'] == 0 then>
something only for guests
</if>

Oh I like this,
MyAdvertizements already offers a setting to show ads in a per group basis on a per ad basis.
(2013-05-18, 10:01 PM)Destroy666 Wrote: [ -> ]You can use Template Conditionals plugin if you want to put the code in templates. http://mybbhacks.zingaburga.com/showthread.php?tid=464
Example code:
<if $mybb->user['uid'] == 0 then>
something only for guests
</if>

If you want to put the code in plugin, use similar condition.
if ($mybb->user['uid'] == 0)
{
    $banner = bannercodeforguestshere;
}

Thanks
You can:
  1. installing an advertising plugin
  2. Use the Hooks Plugin
    In Configuration-Plugin-Hooks-Add a new Hook...
    Hook
    showthread_start
    Title
    Banner
    Priority
    10
    Code
    Global $mybb;
    if($mybb->user['usergroup'] = "4"){
    $mybb->user['banner']= '<b>HTML</b> Code';
    }
    search in (Template & Stili-Template-Template Name-Post Bit Templates-postbit):
    {$post['attachments']}
    add follow:
    {$mybb->user['banner']}
  3. Edit mybb' s core file :
    Open the file global.php in the root directory
    search:
    // Create session for this user
    require_once MYBB_ROOT."inc/class_session.php";
    $session = new session;
    $session->init();
    $mybb->session = &$session;
    add follow:
    if($mybb->user['usergroup'] = "4"){
    $mybb->user['banner']= '<b>HTML</b> Code';
    }
    and edit the template:
    (Template & Stili-Template-Template Name-Post Bit Templates-postbit):
    {$post['attachments']}
    add follow
    {$mybb->user['banner']}
sorry for my English