User login/logout
If it is necessary to execute some code on login or logout of a registered user, it is necessary to create a model named Brixy_Users_Advanced_Model ub folder brixy\App\Models\custom.
You can create two main functions in it:
function after_login_advanced(){
//executed after successful login before custom redirect from Brixy Configuration (if added).
//your code
};
and
function after_logout_advanced(){
//executed after a successful exit from the system (logout).
//your code
};
Redirect examples:
return redirect()->to(route_to('dashboard'))->send();
exit;
//-----------------------------------------
return redirect()->to('https://brixy.dev')->send();
exit;
From each function, other functions can be performed.
function after_login_advanced(){
$this->update_user_last_login();
$this->send_notification();
};
function update_user_last_login(){
$db_conn = make_db_conn(FORUM_CONNECTION_ID);
$builder = $db_conn->table('table_users');
$db_column_to_update = [
'last_login' => get_now(),
];
$builder->where('user_id', getUserID());
$builder->set($db_column_to_update);
$builder->update();
}
function send_notification(){
$to = test_mail@xxx.xxx;
$subject = 'subject';
$body = 'body';
send_mail($to, $toname, $subject, $body);
}