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).
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>";
}
?>