Get user profile & Login activity

Get user profile & Login activity

av Rajakumar Jillella -
Antal svar: 3

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.






Medeltalet av utvärderingarna: -
Som svar till Rajakumar Jillella

Re: Get user profile & Login activity

av Rajakumar Jillella -

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());

}

Medeltalet av utvärderingarna: -
Som svar till Rajakumar Jillella

Re: Get user profile & Login activity

av Gareth J Barnard -
Bild av Core developers Bild av Particularly helpful Moodlers Bild av Plugin developers

Alternatively, see if the information is already in the $USER global and save another DB call.

Medeltalet av utvärderingarna: -