miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /   

Module Color Nick ver 1.0

Author Kimi
Registered
#1 | Posted: 1 Feb 2015 16:33 
Step 1:
Open bb_functions.php and paste script below in end of file:

Function maunick($id, $mod = false) {
/* Function Color Nick by dungitcdt(.)com
* Right = 3: Admin
* Right = 2: Mod
* Right = 1: Member
* Right = 0: Banner
*/
if ($ban = db_simpleSelect(0, $GLOBALS['Tb'], 'banip', 'banip', '=', $id)) $banA=$ban[0];
if ($user = db_simpleSelect(0, $GLOBALS['Tu'], 'rights, username', 'user_id', '=', $id)) $right = $user[0];
If ($ban > 0) {
$out .= '<span style="color:black;">' . $user[1] . '</span>';
} Else {
if ($right > 0) {
if ($right == 1) { $font = '<span style="color:blue;">';}
if ($right == 2) { $font = '<span style="color:green;">';}
if ($right == 3) { $font = '<span style="color:red;">';}
$out .= $font . $user[1] . '</span>';
} else {
$out .= '<span style="color:blue;">' . $user[1] . '</span>';
}
}
return '<b>'.$out.'</b>';
}

Step 2: Add script below to phpmyadmin
ALTER TABLE `minibbtable_users` ADD `rights` INT( 1 ) NOT NULL DEFAULT '1';
UPDATE `minibbtable_users` SET `rights` = '3' WHERE `minibbtable_users`.`user_id` =1;

Okey. How to use?
Example:
$name = maunick($res[2]);

Wish you success! :))

Author Kimi
Registered
#2 | Posted: 1 Feb 2015 16:37 
Demo:i.imgur(.)com/Mgc3p16.png

Author Paul
Lead Developer
#3 | Posted: 1 Feb 2015 19:00 | Edited by: Paul 
Thanks for this. However, we prefer non-core destructive solutions for miniBB. They make upgrades more easier - then you would need just to overwrite core files, without restoring custom codes again and again. Bb_functions.php is a core files... Also, I did not get the idea why would you need to extend the database - making the nickname in various colors could be built on the fly. Also, making a standalone request for the banned status means you would need to create extra 20-30 requests to DB per loading just one thread. Not good.

Here's a non-destructive solution I've created earlier for making the admin nickname in another color in posts. It could be extended to have the same approach for all other users.

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications / Module Color Nick ver 1.0 Top

Your Reply Click this icon to move up to the quoted message

 Short link for this topic:

 ?
Only registered users are allowed to post here. Please, enter your username/password details upon posting a message, or register first.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
 
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
Check out the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB