List: Getting User Report: Time logged in


i need a List showing all Users currently logged in and a list showing Details Time und Date logged in for a specific User.

I cant find the Feature in SuiteCRM.

Can anyone help?

Thanks a lot. :slight_smile:

I don’t think there is an easy way to do this.

There is an after log in hook and an after log out hook, which you could use to write some custom code to store this info.

You need to update custom/modules/logic_hooks.php (or create it if it doesn’t exist in your project) and add the following:

$hook_array[‘after_login’] = Array();
$hook_array[‘after_login’][] = Array(priority, ‘Hook label’, ‘custom/modules/fileWithYourCode.php’,‘Classname’, 'methodName);

Priority is the order hooks run in and should be a number, hook label is any sensible name you want to describe your hook, the next paramater is the file where you will add code, class name is the name of the class in the file and methodname is the method to call.

Your code will then be called automatically whenever a user logs in, so if you create a table to track logged in users in your database then you can insert a user to whenever anyone logs in.

Similarly you’ll need to add an ‘after_logout’ hook to delete a user from the table whenever they log out.

The method you write for the hook will get the $bean and $event passed to it so your code should look something like

<?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class Classname { function methodName($bean, $event, $arguments) { global $db; $username = $bean->user_name; $id = $bean->id; $db->query("insert into yourtablename (userid, username) values ($id, $username)"); } } You should validate the username to prevent potential sql injections and you can add code to store the datetime as well if you want log in time. Then write a similar method to delete the entry when the user logs out. Apologies if there are any syntax errors in this as I've just typed it straight into the forum without testing, but hopefully it should be enough to get you started.