MyBB Community Forums

Full Version: Admin Coloured Posts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm looking to develop a mod (or someone else), where the administrator (or a certain usergroup)'s posts show up in a predefined colour, except when the colour tags are used.

A good example of this, is the World of Warcraft forums, where blizzard representative's posts show up in blue.

Any help on what variables and what hooks to use, since I'm kinda stuck on where abouts it should go. Probably more when displaying the thread.

I'd rather it not be a mod that automatically puts in color tags either.
You could just make groups, then change the colors of the groups?
ohh, what do you mean by "changing the colours of the groups"?
sorry, "bumping" for some more help. I'm kinda stuck on this one unfortunately.
mmm... that a good idea, id definatly use this modification. good for popular forums where theres alot of members and the admins/mods/+Members want to stand out.....


Sorry i cannot help in this mods development :-(
Ok,

I made the plugin, however it doesnt seem to be working >_>

It works on my local computer (apache) but not where my website is hosted.

Could someone please have a look and see what I've missed? Smile

PHP Code:
<?php
/**
 * MyBB 1.1
 * Copyright � 2005 MyBulletinBoard Group, All Rights Reserved
 *
 * Website: http://www.mybboard.com
 * License: http://www.mybboard.com/eula.html
 *
 * $Id: postcolour.php 661 2006-08-12 04:44am Netrosis $
 */

$plugins->add_hook("postbit""postcolour");

function 
postcolour_info()
{
    return array(
        
"name"            => "Coloured Posts",
        
"description"    => "A Plugin that will change the colour of posts for a usergroup.",
        
"website"        => "http://www.mybboard.com",
        
"author"        => "Netrosis",
        
"authorsite"    => "http://www.artificialentertainment.net",
        
"version"        => "1.0",
    );
}

function 
postcolour_activate()
{
    global 
$db;
    
    
$pc_group = array(
        
"gid"            => "NULL",
        
"name"            => "Post Colour Settings",
        
"description"    => "Settings for the Post Colour plugin.",
        
"disporder"        => "",
        
"isdefault"        => "no",
    );
    
    
$db->insert_query(TABLE_PREFIX."settinggroups"$pc_group);
    
$gid $db->insert_id();
    
    
$pc_setting_1 = array(
        
"sid"            => "NULL",
        
"name"            => "postcolour",
        
"title"            => "Colour",
        
"description"    => "The Colour you want the post to display as",
        
"optionscode"    => "",
        
"value"            => "#0066CC",
        
"disporder"        => "1",
        
"gid"            => intval($gid),
    );
    
    
$pc_setting_2 = array(
        
"sid"            => "NULL",
        
"name"            => "postcolourgroup",
        
"title"            => "Usergroup",
        
"description"    => "The usergroup number to change post colours too. Default is \"4\" (Administrators).",
        
"optionscode"    => "",
        
"value"            => "4",
        
"disporder"        => "2",
        
"gid"            => intval($gid),
    );
    
    
$db->insert_query(TABLE_PREFIX."settings"$pc_setting_1);
    
$db->insert_query(TABLE_PREFIX."settings"$pc_setting_2);
}

function 
postcolour_deactivate()
{
    global 
$db;
    
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('postcolour', 'postcolourgroup')");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='Post Colour Settings'");
}

function 
postcolour()
{
    global 
$post$settings;
    if (
$post['usergroup'] == $settings['postcolourgroup'])
    {
        
$post['message'] = '<font color="' $settings['postcolour'] .'">' $post['message'] . '</font>';
    }
}
?>

In, yet another edit, the following code works. So there must be something with the settings >_>

PHP Code:
function postingcolour()
{
    global 
$post$settings;
    if (
$post['usergroup'] == "4")
    {
        
$post['message'] = '<font color="#0066CC">' $post['message'] . '</font>';
    }

Sorry about the bump.

I'm just stumped on why its working on one version of my forums and not the other. The options all come up in the admin board settings. However it won't do what its supposed to do. The code doesn't show up, when it should.

I double checked the usergroup settings too. :|

any help would be appreciated!!
Isn't it $mybb->settings['postcolourgroup'] ; $mybb->settings['postcolour'] and add $mybb as a global.
But in your code, i can't figure out how its ever gonna change the colour of the postmessage =z You could change the color of the message, just before its entered in the DB ... in newreply.php and newthread.php
either code worked, once again, on my testing server, but not on the live version of the forums. Confused

it works by adding a
<font color="#000000">
before and
</font>
after the post message, so that whatever colour you specify, it will display. Theres one set of code that works, however I just wanted to add a bit of customisation to it by putting the settings in the ACP so that they could be changed without editing the file.
Well if your first code doesn't work, and your second code with the color changes in it works....

Then it is probably a problem with this variable: $settings['postcolourgroup']
and probably this variable as well $settings['postcolour']

Are you sure that those are the correct variables?
Like the previous poster said.... that the variables are probably $mybb->settings['postcolourgroup'] and $mybb->settings['postcolour']

So try the following code:
<?php
/**
 * MyBB 1.1
 * Copyright � 2005 MyBulletinBoard Group, All Rights Reserved
 *
 * Website: http://www.mybboard.com
 * License: http://www.mybboard.com/eula.html
 *
 * $Id: postcolour.php 661 2006-08-12 04:44am Netrosis $
 */

$plugins->add_hook("postbit", "postcolour");

function postcolour_info()
{
    return array(
        "name"            => "Coloured Posts",
        "description"    => "A Plugin that will change the colour of posts for a usergroup.",
        "website"        => "http://www.mybboard.com",
        "author"        => "Netrosis",
        "authorsite"    => "http://www.artificialentertainment.net",
        "version"        => "1.0",
    );
}

function postcolour_activate()
{
    global $db;
    
    $pc_group = array(
        "gid"            => "NULL",
        "name"            => "Post Colour Settings",
        "description"    => "Settings for the Post Colour plugin.",
        "disporder"        => "",
        "isdefault"        => "no",
    );
    
    $db->insert_query(TABLE_PREFIX."settinggroups", $pc_group);
    $gid = $db->insert_id();
    
    $pc_setting_1 = array(
        "sid"            => "NULL",
        "name"            => "postcolour",
        "title"            => "Colour",
        "description"    => "The Colour you want the post to display as",
        "optionscode"    => "",
        "value"            => "#0066CC",
        "disporder"        => "1",
        "gid"            => intval($gid),
    );
    
    $pc_setting_2 = array(
        "sid"            => "NULL",
        "name"            => "postcolourgroup",
        "title"            => "Usergroup",
        "description"    => "The usergroup number to change post colours too. Default is \"4\" (Administrators).",
        "optionscode"    => "",
        "value"            => "4",
        "disporder"        => "2",
        "gid"            => intval($gid),
    );
    
    $db->insert_query(TABLE_PREFIX."settings", $pc_setting_1);
    $db->insert_query(TABLE_PREFIX."settings", $pc_setting_2);
}

function postcolour_deactivate()
{
    global $db;
    
    $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('postcolour', 'postcolourgroup')");
    $db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='Post Colour Settings'");
}

function postcolour()
{
    global $post, $settings;
    if ($post['usergroup'] == $mybb->$settings['postcolourgroup'])
    {
        $post['message'] = '<font color="' . $mybb->$settings['postcolour'] .'">' . $post['message'] . '</font>';
    }
}
?>

I don't know if it will work or not, as i did not try it. But the only difference in your code is that you changed the variables to actual values. (because it worked, that means that one of more of those two variables probably contain a null or incorrect value)
Pages: 1 2