Adding the first [gs snippet] to the functions.php of your WordPress [gs theme] will capture a users last login time.
Add the second snippet to the location you wish to display the users last [gs login] time.
First Snippet
function your_last_login($login) {
global $user_ID;
$user = get_userdatabylogin($login);
update_usermeta($user->ID, 'last_login', current_time('mysql'));
}
add_action('wp_login','your_last_login');
function get_last_login($user_id) {
$last_login = get_user_meta($user_id, 'last_login', true);
$date_format = get_option('date_format') . ' ' . get_option('time_format');
$the_last_login = mysql2date($date_format, $last_login, false);
echo $the_last_login;
}
Second Snippet
<?php
global $userdata;
get_currentuserinfo();
echo 'You last logged in:';
get_last_login($userdata->ID);
?>
SOURCE | LINK (joomquery.com) | LANGUAGE | ENGLISH |