PDA

View Full Version : Problems With logout_process Hook


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.

kh99
03-03-2012, 12:46 PM
It seems to work for me. Are you sure there are no other plugins that could be resetting the status after logout_process?

nitroviper_work
03-05-2012, 08:02 PM
Thank you for taking the time to test it, kh99. I really appreciate it!

Reading your post gave me an idea. While there were no other plugins resetting the status, there was a faulty line of javascript that would. Correcting that javascript error fixed my issue.