Get user profile & Login activity

Get user profile & Login activity

por Rajakumar Jillella -
Número de respostas: 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.






Média das avaliações:  -
Em resposta à Rajakumar Jillella

Re: Get user profile & Login activity

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

}

Em resposta à Rajakumar Jillella

Re: Get user profile & Login activity

por Gareth J Barnard -
Imagem de Core developers Imagem de Particularly helpful Moodlers Imagem de Plugin developers

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