Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Last time a user logged in

I don’t see anything like it in the database, so you probably have to do this yourself. To save the last login time, you can hook into the wp_login action, and save a user meta value (like [myprefix]_lastlogintime). You first read this value, so you get the previous login time, save this in the session, and then save the new login time.

On the regular admin pages you check whether this session variable is set. If it is, you display the welcome text and clear the session variable so you don’t display it on every page.

If you want to save the last page visit time you have to write to the database on every (admin) page view. This is possible, but I would not recommend it. You can also save something once on logout (action wp_logout), but probably not everyone will remember to log out.

Related Posts:

  1. How can I allow access to multiple users, using the same login, at the same time?
  2. User can not login
  3. Multi-site User Sessions
  4. Change the login button on the login page
  5. How to update the delete user confirmation form?
  6. Custom ReCaptcha Login
  7. What is the proper way to apply the login_form_bottom filter?
  8. How to override wp-login.php
  9. Remove Links from Login page
  10. Modify custom Users Manage page
  11. How to Save Different Usermeta Fields According to User Role?
  12. Show newly added posts since last user login time /date
  13. setting a specific home page for logged in users
  14. Change “logged in” link in (you must be logged in to post a comment)
  15. Redirect to requested page after (custom) login
  16. Associate Page with User
  17. Set user loggin status?
  18. Customizing the default logout page of WordPress
  19. How do I remove the eye icon that shows visibility on login screen and reset password screen
  20. How can I add data to a custom column in the Users section of the wordpress backend?
  21. Unique User Account Number + Displayed Via Shortcode
  22. Custom Login and Registration form in Ajax
  23. Updating Custom WordPress User Meta Field via REST API
  24. How to pass external variables to the wp_new_user_notification_email filter?
  25. Creating user relationships
  26. WordPress custom login page
  27. Function to allow “Anyone can register”?
  28. Make custom user table column filterable
  29. Adding a login form that concatenates three fields into a username
  30. Add ‘Creator’ User Meta when adding user
  31. Properly customizing login/register form
  32. WordPress Locale Switching on Accept-Language Header
  33. Follow me for WordPress blogs (multi-authors)
  34. Change the Labels of Users to Customers in Admin
  35. How to add an extra variable to login and authenticate it?
  36. Login/Logout Session Sharing – Multiple WordPress Installations
  37. Custom login with external provider iframe and data object
  38. Deep customization of wp-login.php
  39. Allow guests to use WP Customizer but disable save button
  40. Lost password empty field error redirect to custom login
  41. Users can only view their content from the front end
  42. Custom Log In Screen – Disable password recovery [duplicate]
  43. List top 5 authors with most posts
  44. A truely custom login page?
  45. Problem with custom user meta field
  46. Switch between WordPress websites easy for an end user
  47. Lost password and back to blog in same line
  48. Customizing Users in Admin Area
  49. I w’d like to know If there are simple solutions to integrate other CMSs to wordpress
  50. how to make a custom field readonly or disabled by user role?
  51. How to make wordpress use a non-wordpress users table?
  52. Delete a user from frontend
  53. Restrict content access to logged in users
  54. Custom login and registration forms
  55. loginout function customization
  56. URL and Site title outputting on Login page
  57. Is it possible to integrate a custom login feature with wordpress?
  58. Personalized Gallery what are my options?
  59. how or where wordress collect unlogged user session
  60. How to change the login page without a plugin and not only customizing logo and text around the form?
  61. Removing “Failed” query argument upon successful login
  62. Validate user login in php
  63. No plugin populate user information in to form
  64. How to block specific user id in custom login form?
  65. how to change the url rediction of the woocommerce login page of the flatsome theme for my own in wordpress?
  66. Invitation link to a site in multisite network does not work?
  67. How to change Login default blue admin color?
  68. Latest update broke my custom login CSS
  69. WP_User_Query Search Multiple Keywords from a Multi-Select Field?
  70. Trouble with custom login page
  71. Wrap WordPress Login Form in custom Div
  72. Custom login doesn’t stay
  73. Check get_post value after wp-admin login
  74. where can i find the login page in wordpress and add my header to it
  75. How to display all post from the same current usermeta
  76. Highlight specific user with custom field value
  77. Change the default WordPress image on the dashboard login to a custom image [duplicate]
  78. Change the functionality of wordpress users module in admin
  79. Pass the post ID
  80. Changing starting number of User ID
  81. Custom search by several options send on form not works
  82. User registration add user ID?
  83. How to create functions that affect only a specific user
  84. Show Site Name on WP login screen
  85. Create users via PHP
  86. Use wp_login_form function to login with a custom user table?
  87. how to manage Session in WordPress using custom login?
  88. Is it possible assign a secondary existing role to already existing one?
  89. Redirect all pages to the custom login page except for the registration page
  90. How to stop login for SPECIFIC users BEFORE a specified date
  91. User Query Multiple Orderby Clause
  92. Some data of one custom user profile is erased when I update another custom user profile
  93. Must I rewrite the whole login form or can I jsut do a part
  94. How to add functionality to an existing theme (using child themes)
  95. How to add WordPress JS Script Links
  96. How to add page content into another page
  97. Display content of metabox if filled in
  98. Showing Meta Box via Jquery Checkbox
  99. Localhost wordpress access remote db wordpress website
  100. add_action does not work when instance multiple tab-containers via template-file
Categories customization Tags customization, date-time, login, users
Most Flexible Photo Gallery Plugin? [closed]
Feature Differences between WordPress.com and Hosting on your Own Server?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress