How to get the users post count on (costum) page

Started by Pipke, September 09, 2014, 05:29:37 PM

Previous topic - Next topic

Pipke

Like the title says, how to get how many posts they made on the forum. The code is on Display.template.php but i want it to use it for a costum page.
tryed:
<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>
<li class="postcount">', $txt['member_postcount'], ': ', $context['user']['posts'], '</li>';

both show nothing, i guess the costum page isnt loading Load.php?


also cannot get it from the SSI file with print_r($context['user']);

so is there some quick way in smf to get it?
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Kindred

no... everything uses load.php...  what the problem is is that $message is only defined when display and a few other templates are loaded...

and even the post count in content is not always filled...


so - no...  there is no "quick way" you have to pull it form the database
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

$user_info['posts'] contains the post count of the current user, not formatted wth commas or anything.

Make sure you declare it as global, and you should be good to go (and wrap it as comma_format($user_info['posts']) if you want the comma in there)

Pipke

Quote from: Arantor on September 09, 2014, 06:09:06 PM
Make sure you declare it as global, and you should be good to go (and wrap it as comma_format($user_info['posts']) if you want the comma in there)
Oh crap i forgot to declare that in global, how stupid, thx for the help got it working now.
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Kindred

Doh! So focused on context, I forgot about user_info..

Good call Arantor.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: