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

Custom title next to username in the messages thread

Author tom322
Registered
#1 | Posted: 12 Dec 2008 23:37 | Edited by: tom322 
I wanted to put some text next to some usernames, let's say user_ids: 2266 and 5455. I understand I should do it by using the parseUserInfo function.

So I included this code in bb_plugins.php:

function parseUserInfo_user_customtext($val){

if ($GLOBALS['user_id']==2266 or $GLOBALS['user_id']==5455) return ' <b>[custom text next to username]</b>';

}

Then I copied {$userInfo_user_customtext[$poster_id]} to main_posts_cell.tpl (next to {$posterName}).

Please tell me what is wrong with this code because it didn't work:). Thank you.

Tom

Author tom322
Registered
#2 | Posted: 13 Dec 2008 10:08 
I also tried these two codes below, but they didn't work either..

1. --------------

function parseUserInfo_user_customtext($val){

if ($GLOBALS['cols'][0]=2266 or $GLOBALS['cols'][0]=5455) return ' <b>[custom text next to username]</b>';

}

2. --------------

function parseUserInfo_user_customtext($val){

if ($val=2266 or $val=5455) return ' <b>[custom text next to username]</b>';

}

Author tom322
Registered
#3 | Posted: 13 Dec 2008 21:33 
I guess I should add I need it on the thread pages, ie. $action=='vthread' (not userinfo pages). Thank you!

Author Paul
Lead Developer
#4 | Posted: 18 Dec 2008 02:20 | Edited by: Paul 
I suppose most of the task could be done specifying $userRanks array, which handles almost the same things as you are trying to put (special rankings for the user). 'Admin' and 'moderator' are already appearing automatically in miniBB already. I personally would avoid any duplications on the screen, specially that ones which affect user's statuses and ranks etc.; but anyway, the code is attached.

parseUserInfo function works both for the user's profile and 'vthread'. parseMessage is for 'vthread' only, so if this is only for 'vthread', we shall use it instead of parseUserInfo. 'vthread' is more correct way also in a case of referring variables.

Here is what you need to put in:

bb_specials.php - specify new array defining your very custom titles that way:

$specialTitles=array(
1=>'<strong>Community Chief</strong>',
2=>'Rocking Guy',
3=>'Relaxing Girl',
);

assigning user IDs and titles. Then modify bb_plugins.php, and add to the end of parseMessage function before closing bracket, the following code:

function parseMessage(){

/* Special member titles */

$uid=$GLOBALS['poster_id'];

$isMod=FALSE;
if(is_array($GLOBALS['mods'])){
foreach($GLOBALS['mods'] as $key=>$val) if(is_array($val) and in_array($uid, $val)) {
$isMod=TRUE; break;
}
}

if($isMod) $GLOBALS['userSpecialTitle']='<em>Moderator</em>';
elseif(isset($GLOBALS['specialTitles'][$uid])) $GLOBALS['userSpecialTitle']=$GLOBALS['specialTitles'][$uid];
else $GLOBALS['userSpecialTitle']='';

if($GLOBALS['userSpecialTitle']!='') $GLOBALS['userSpecialTitle'].='<br />';

/* --Special member titles */

}


Such function is used widely for many other add-ons, so you need either to extend it either to create from scratch, but not duplicate it, because it will stop forums program to run.

Finally, paste {$userSpecialTitle} in main_posts_cell.html template in the place you would like such title to appear.

Author tom322
Registered
#5 | Posted: 18 Dec 2008 16:34 | Edited by: tom322 
Thank You, Paul! I would have never done it myself :). It works correctly.

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications / Custom title next to username in the messages thread Top

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

 Short link for this topic:

 ?
You are welcome to post anonymously, by entering a nickname with no password (if the similar Username has not been taken yet), or by leaving both fields empty. If you have a forums account, you can also sign in from this page without posting a message, or sign in and post at once.


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
Install the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB