miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

Add profile fields on Post View

 
Author Matteo96
Partaker
#1 | Posted: 22 Aug 2024 11:11 
Goodmorning,

I am using the official modification user ranks but I got a problem, before the rank that is showed correctly I get «Partaker». I attach a screenshot. Also just after the rank I would like to display: Post Count, Registration Date and Location. What are those template variables?



Thank you!

Author Paul
Lead Developer 
#2 | Posted: 22 Aug 2024 19:26 
Matteo96:
I got a problem, before the rank that is showed correctly I get 'Partaker'.
Yes, it's supposed to work that way by default, it just adds a new value to the member's title, but it doesn't replace it.

If you'd like to remove the title and leave only the rank, modify /templates/main_posts.html and delete {$viewReg} code.

Also, modify bb_plugins.php -> parseUserInfo_num_posts function, and change this code:

return '& n b s p ;'.$rank;
to this:

return $rank;
— this will eliminate an unnecessary space before the rank.

Note there are basically 4 titles which could be present on the forum: Admin, Moderator, Partaker and Guest. I suppose, there's nothing critical if the title is hidden for Guests (specially if you have members-only forum), but it could be critical to not see the Admin or Moderator.

In this case, you can re-assign their titles in bb_specials.php -> $userRanks array, specifying their IDs and special titles. What's provided in $userRanks is always taken first, so this will also override what's generated in parseUserInfo_num_posts function.

Author Paul
Lead Developer 
#3 | Posted: 22 Aug 2024 19:44 
Matteo96:
Also just after the rank I would like to display: Post Count, Registration Date and Location.
Here's the question is not about the ranks, but how to display different values based on user's profile.

At first, you have to define them all in $userInfoInPosts array of setup_options.php. Example from miniBB demo:

$userInfoInPosts=array('user_custom1', 'user_custom2', $dbUserSheme['num_posts'][1], 'user_custom3', $dbUserSheme['username'][1], 'user_custompics');
So, this could be done basing on what's provided $dbUserSheme set above, or just straight DB table names.

Then in bb_plugins.php, you have to define a standalone function for each value in this array, naming it parseUserInfo_FIELDNAME($val), where FIELDNAME stands for a field name.

$val is what this function gets from the topic displaying script, and you can operate it in any way you want. On the topic page, there will be displayed what this function returns back. Then in templates/main_posts.html, for each field you have to paste: {$userInfo_FIELDNAME[$poster_id]}.

I will show your case on easiest examples:

— setup_options.php:

$userInfoInPosts=array($dbUserSheme['num_posts'][1], $dbUserDate, $dbUserSheme['user_from'][1]); //paste this below the $dbUserSheme definition
— bb_plugins.php:

function parseUserInfo_user_regdate($val){

return 'Registered on: '.convert_date($val).'<br>';

//paste in main_posts.html: {$userInfo_user_regdate[$poster_id]}

}

function parseUserInfo_user_from($val){

if($val!='') return 'From: '.$val.'<br>';
else return '';

//paste in main_posts.html: {$userInfo_user_user_from[$poster_id]}

}
And if you have installed the Ranks add-on, it already generates values based on the num_posts field, so — this function has to be extended, but NOT specified twice (this will lead to the duplication error in PHP). Here's an example on the default function:

function parseUserInfo_num_posts($val){
if($GLOBALS['action']=='userinfo') return $val-$GLOBALS['row'][10];
elseif($GLOBALS['cols'][0]!=1 and !isset($GLOBALS['userRanks'][$GLOBALS['cols'][0]])){

//Put the amount of posts (from...to) and the special rank. You could also put stars (*****) instead of a word, or graphics with <img> tag and pre-created images.
if($val>=1 and $val<=10) $rank='Starter';
elseif($val>10 and $val<=30) $rank='Expert';
elseif($val>30 and $val<=1000) $rank='Profy';
elseif($val>1000 and $val<=1500) $rank='Rich';
elseif($val>1500) $rank='Upscale';

else $rank='';
return ' '.$rank.'<br>Posts: '.$val;
}
}
I didn't try it all — feel free to post here if something doesn't work.

Author Matteo96
Partaker
#4 | Posted: 22 Aug 2024 21:42 
Oh thank you so much! worked!

Author Paul
Lead Developer 
#5 | Posted: 23 Aug 2024 00:33 
Perfect! You're welcome 🙂

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 Add profile fields on Post View
 Share Topic's Link

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


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Get the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑