2011-12-28, 01:50 AM
Ok so I couldn't find a plugin for this originally, so I decided to start making my own (I have never made a plugin, so this got real interesting really fast).
I am basically stuck with an error/bug, not really an error so I guess it's a bug. I better give you the general layout of the plugin first:
I want users to be awarded 5 rep points for every "x" posts they get, this rep will be given by a user called "System". The part of giving the initial rep works fine, but it's the part afterwords that gets buggy...
I used the hook post_output_page to run the function, which I may have messed up right there. I made the function to test on my own user first, and when I hit the required posts to get the rep, it just keeps giving it until I disable the plugin. Here is my full code:
Don't mind the "607", that is just to test on my own user. I tried putting "return;" at the end to stop it from repeating the rep giving process, but it didn't work.
Any suggestions?
I am basically stuck with an error/bug, not really an error so I guess it's a bug. I better give you the general layout of the plugin first:
I want users to be awarded 5 rep points for every "x" posts they get, this rep will be given by a user called "System". The part of giving the initial rep works fine, but it's the part afterwords that gets buggy...
I used the hook post_output_page to run the function, which I may have messed up right there. I made the function to test on my own user first, and when I hit the required posts to get the rep, it just keeps giving it until I disable the plugin. Here is my full code:
<?php
if(!defined('IN_MYBB'))
{
die();
}
function postrep_info()
{
return array
(
"name"=>"Reps based on post count",
"description"=>"Reputation increments as posts increase",
"website"=>"http://tah4t.com/",
"author"=>"Nick Wilging",
"authorsite"=> "http://tah4t.com/",
"version"=>"1.0",
"compatibility"=>"16*"
);
}
function postrep_activate()
{
}
$plugins->add_hook("post_output_page", "post_rep");
function post_rep()
{
global $mybb, $db;
$group = $mybb->user['usergroup'];
$postcount = $mybb->user['postnum'];
$thisuser = $mybb->user['uid'];
$datenow = TIME_NOW;
$data = array(
'rid' => '0',
'uid' => $thisuser,
'adduid' => '1',
'pid' => '0',
'reputation' => '5',
'dateline' => $datenow,
'comments' => 'Post Count'
);
if($mybb->user['uid'] != "0")
{
if($postcount == "607")
{
$db->insert_query('reputation', $data);
return;
}
}
}
?>
Don't mind the "607", that is just to test on my own user. I tried putting "return;" at the end to stop it from repeating the rep giving process, but it didn't work.
Any suggestions?