I'm using Moodle 3.2.
How can we get current logged in user "Login Activity", and user profile.
Ex :
User Name : XXXX
Role : Student / Teacher / Admin
And login activity.
Hi,
I have written a small code with DB tables to get login activity.
Here is my code
echo "<h3>Login Activity</h3>";
$login = mysql_query("SELECT * FROM mdl_user WHERE id=$USER->id");
while($result = mysql_fetch_array($login)){
$firstaccess = $result['firstaccess'];
$lastaccess = $result['lastaccess'];
echo "<span style='font-weight: bold;'>First access to site :</span> ".date('l, d / M / Y', $firstaccess);
echo "<br /><span style='font-weight: bold;'>Last access to site :</span> ".date('l, d-M-Y', $lastaccess).", ".date("G:i:s", time());
}
Alternatively, see if the information is already in the $USER global and save another DB call.
yes.. $USER will always have those info you need
thanks