okay, here goes the full plugin, with some extra stuff i added
hook location: newpost_complete
PHP Code:
if ($vbulletin->userinfo['referrerid'] > 0 AND $foruminfo['countposts'] AND $vbulletin->userinfo['posts'] + 1 == 50){
$ref_raw = $db->query_read("SELECT username FROM user WHERE userid = ".$vbulletin->userinfo['referrerid']);
$ref_nam = $db->fetch_array($ref_raw);
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$pmdm->set('fromuserid', 1);
$pmdm->set('fromusername', Administrator);
$pmdm->set('title', 'Congratulations');
$pmdm->set('message', "congratulations! you have referred the user ".$vbulletin->userinfo['username']." and he has made 50 posts");
$pmdm->set_recipients($ref_nam['username'], $permissions);
$pmdm->set('dateline', TIMENOW);
$pmdm->pre_save();
// process errors if there are any
$errors = @array_merge($errors, $pmdm->errors);
if (!empty($errors))
{
$errorlist = '';
foreach ($pmdm->errors AS $index => $error)
{
$errorlist .= "<li>$error</li>";
}
}
else
{
// everything's good!
$pmdm->save();
}
}
the weird part about this code is that i have tried it on a separate php file under the same directory as the forums that calls includes the file global.php and the whole thing works fine in that separated file, as well i tried to see if this hook had any conflict with others, so i disabled everything and still the problem persist
thanks!