Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Created November 22, 2011 21:12
Show Gist options
  • Save wpscholar/1386981 to your computer and use it in GitHub Desktop.
Save wpscholar/1386981 to your computer and use it in GitHub Desktop.
WordPress - Store timestamp of a user's last login as user meta
/**
* WordPress - Store timestamp of a user's last login
*/
function user_last_login( $user_login ){
$user = get_user_by('login', $user_login);
if( $user ){
update_user_meta( $user->ID, '_last_login', time() );
}
}
add_action( 'wp_login', 'user_last_login' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment