View Full Version : Member Profile Hook Location
dfc005
01-13-2009, 09:35 PM
Hey guys,
I've written a little plugin to calculate some stats about a users posting. I'd like to add these new stats to the "Statistics" tab on the members profile page. So, added the variables to the 'memberinfo_block_statistics' template but can't seem to get it to work for the life of me.
Any idea what hook I need to use for that to work? Have tried a bunch including 'member_complete' and 'profile_complete' but non seem to work.
My plugin does the right calculations as I can print out the stats from within the plugin, they just never seem to show up in my templates.
Cheers.
Lynne
01-13-2009, 10:37 PM
How about member_build_blocks_start? Take a look at the member.php page and see all the hooks in there, don't just randomly pick one from the drop-down (profile hooks are from a complete different page).
dfc005
01-13-2009, 10:50 PM
Hmmm, OK. The hooks on the member.php page are....
member_start
member_start_fetch_user
member_execute_start
member_build_blocks_start
member_complete
Tried all of those and no dice. As I said, I've added the variables to be outputted into the 'memberinfo_block_statistics' template. It has a template hook called 'profile_stats_first' right at the start of it which was why I was using the profile hooks.
Bellardia
01-13-2009, 11:30 PM
Are you sure it's the hooks that aren't working and not the code?
dfc005
01-13-2009, 11:34 PM
Righto, I put an echo in the plugin to print out the new stat. Using member_build_blocks_start, I see the stat at the top of the page but not in the Statistics tab like it should be.
So, I assume the plugin is being executed but the code I have in the template is not working then?
Here's the code quickly....
Plugin
$stats= $db->query_read("
SELECT round(sum(replycount)/count(*),2) AS average, round(sum(views)/count(*),2) AS strikerate
FROM `thread`
WHERE `forumid` != 384
AND `forumid` != 20
AND `forumid` != 375
AND `postuserid` = $userinfo[userid]
");
$stat = $db->fetch_array($stats);
$thread_average = $stat['average'];
$thread_strikerate = $stat['strikerate'];
echo $thread_average;
Template
<li><span class="shade">$vbphrase[total_posts]:</span> $prepared[posts]</li>
<li><span class="shade">$vbphrase[posts_per_day]:</span> $prepared[postsperday]</li>
<li><span class="shade">Thread Average (replies):</span> $thread_average</li>
<li><span class="shade">Thread Strike Rate (views):</span> $thread_strikerate</li>
Am I missing something?
Lynne
01-14-2009, 02:32 AM
In your template, try calling it $GLOBALS[thread_average] instead.
dfc005
01-14-2009, 02:41 AM
Bingo! That works wonderfully now. Cheers Lynne!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.