2011-12-12, 01:24 AM
I am developing a plugin that counts the amount of threads a user has made. It works, however when I deactivate then reactivate it sort of "executes" the plugin again (see image).
![[Image: croppedi.png]](https://camo.mybb.com/aa582af936b70b9c84548d78dc888dd6846ad1fc/687474703a2f2f696d673137312e696d616765736861636b2e75732f696d673137312f393031392f63726f70706564692e706e67)
I'm not sure why it does this, my code is as follows.
I'm not sure why it does this, my code is as follows.
<?php
$plugins->add_hook('member_profile_end', 'tcount');
function tcount_info()
{
return array(
"name" => "tcount",
"description" => "Shows threads made in members profile.",
"website" => "",
"author" => "",
"authorsite" => "",
"version" => "1.0",
"compatibility" => "16*"
);
}
function tcount_activate()
{
global $db, $mybb, $templates;
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("member_profile", '#{\$reputation}#', "{\$reputation}\n{\$tcount}\n");
}
function tcount_deactivate()
{
global $db, $mybb;
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("member_profile", '#(\n?){\$tcount}(\n?)#', '', 0);
}
function tcount()
{
global $mybb, $theme, $templates, $db, $tcount, $memprofile;
$query = $db->simple_select("threads", "*", "uid='".$mybb->input['uid']."'");
$tcount = "<tr>
<td class=\"trow1\"><strong>Threads:</strong></td>
<td class=\"trow1\">{$db->num_rows($query)}</td>
</tr>";
}
?>