View Full Version : Adding value to database when successfully logged in
Sangheili
08-13-2012, 05:57 AM
I've been trying to play around with adding a value to the database whenever a successful login is made by the user, I assume it's meant to go in functions_login?
I would ideally like to add a value to the 'loggedin' column of the users row in the database but only when they successfully login. Could someone give me an idea of how to structure this code please?
If you mean you want to save data whenever the user enters their password (and not when they're using "remember me"), then you could use the hook login_verify_success (in function verify_authentication(), in includes/functions_login.php around line 201), or the hook login_process (function_login.php, line 362).
If you want to do it whenever a new session is created (by entering the password or by having a "remember me" cookie), then I think you could use hook global_shutdown (in function exec_shut_down(), in includes/functions.php around line 8043). If you look at the code below where that hook is called you'll see where it checks to see if the user just logged in. I think if you did this:
if (is_object($vbulletin->session) AND $vbulletin->session->vars['loggedin'] == 1 AND $vbulletin->session->created)
{
// just created new session for logged in user
}
The login_process hook doesn't seem to be called when logging in with a cookie (as happens when "remember me" was previously checked).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.