nitroviper_work
03-02-2012, 11:39 PM
I'm looking for help and advice concerning the logout_process hook.
I have a plugin on this hook which calls a function, which updates the database. Oddly, this update will only go through when I die() at the end of the hook, otherwise the logout proceeds as if the plugin didn't exist. Is there a reason for this, maybe something to do with the logout redirect?
The code of the plugin itself just includes the actual plugin file; i.e., include('modfolder/hooks/logout_process.php'). The contents of this file are below.
require_once('mymod/includes/mymod_functions.php');
$db =& $vbulletin->db;
$userinfo =& $vbulletin->userinfo;
update_status($vbulletin->userinfo['userid'],'happy');
The update_status function is declared in the mymod_functions.php file, and its contents are below.
function update_status($userid, $status) {
global $db;
$ts = time();
$status_row = $db->query_first("SELECT * FROM mymod_status WHERE userid = {$userid}");
if(empty($status_row)){
$db->query_write("INSERT INTO mymod_status (userid, status,last_ping) VALUES({$userid},'{$status}',{$ts})");
} else {
$db->query_write("UPDATE mymod_status SET status = '{$status}', last_ping = {$ts} WHERE userid = {$userid}");
}
}
Helpz plox.
I have a plugin on this hook which calls a function, which updates the database. Oddly, this update will only go through when I die() at the end of the hook, otherwise the logout proceeds as if the plugin didn't exist. Is there a reason for this, maybe something to do with the logout redirect?
The code of the plugin itself just includes the actual plugin file; i.e., include('modfolder/hooks/logout_process.php'). The contents of this file are below.
require_once('mymod/includes/mymod_functions.php');
$db =& $vbulletin->db;
$userinfo =& $vbulletin->userinfo;
update_status($vbulletin->userinfo['userid'],'happy');
The update_status function is declared in the mymod_functions.php file, and its contents are below.
function update_status($userid, $status) {
global $db;
$ts = time();
$status_row = $db->query_first("SELECT * FROM mymod_status WHERE userid = {$userid}");
if(empty($status_row)){
$db->query_write("INSERT INTO mymod_status (userid, status,last_ping) VALUES({$userid},'{$status}',{$ts})");
} else {
$db->query_write("UPDATE mymod_status SET status = '{$status}', last_ping = {$ts} WHERE userid = {$userid}");
}
}
Helpz plox.