Try this, notice how I set the 3rd value of get_user_meta() to “true”
function user_last_login_list( $user_login, $user ) {
// If last_login user meta exist
if(metadata_exists( 'user', $user->ID, 'last_login' )){
// Get all login dates as a single array
$UserLoginDate = get_user_meta($user->ID, 'last_login', true);
} else {
// Initialize as an empty array if it's the first time user logs on
$UserLoginDate = [];
}
// Add the current day to array of login dates
$UserLoginDate[] = time();
// Update user meta with the updated array
update_user_meta( $user->ID, 'last_login', $UserLoginDate );
}
add_action( 'wp_login', 'user_last_login_list', 10, 2 );
Related Posts:
- Generate email on meta value update
- How is it possible to current user info on page in WordPress?
- Can’t log in: “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”
- SSO / authentication integration with external ‘directory service’
- Preventing session timeout
- Check for correct username on custom login form
- ‘Password field is empty’ error when using autofill in Chrome
- Prevent wp_login_form() from redirecting to wp-admin when there are errors
- How to disable autocomplete on the wp-login.php page
- how to display the wordpress login and register forms on a page?
- How can I add a custom script to footer of login page?
- Is it alright for two people to simultaneously be logged into a WP site as administrator?
- How do I turn off the ability to login?
- Give visitor access to password protected page/post via external script
- WordPress Login Footer URL
- Change Login Page for a Multisite Subsite
- moving server can not login
- Save last login date in global before change it?
- Login with cookie but without using WordPress code
- How to get login data (session) outside WordPress?
- password protect individual pages
- Change register form action url
- Can’t access login page after password reset
- Rendering of custom walker menu function not working properly
- Is back-end access not required for an app to post to my blog?
- Store brute-force IP addresses
- How do I make my site publicly viewable? Everything redirects to wp-admin
- How to create a private login page for admin.?
- WordPress Security – How to block alternative WordPress access
- Protecting WordPress login page
- Different homepage for logged in users
- How To Change Wp Register/Login URL Permanently To My Custom Page
- reset password link redirect to login page
- get_*_meta doesn’t always return an array
- Deregister default wp-admin css on login screen only?
- How to redirect on login to a specific page if a specific meta user is empty
- Should I encrypt the response that triggers an Ajax action? Is nonce sufficient?
- SSO to WP, from a non-wp site on a different domain and server
- How can I login as admin after redirect to custom login page
- Login with serialized password
- is_user_logged_in() not working in Firefox
- Get the url of custom login page in the registration page
- Why would the login page reload indefinitely?
- How to get all users by custom current user meta (array)?
- Set Default User Role
- Creating custom login errors
- Lock out all WordPress Administrators except two specific users
- Removing wordpress cookie from non-wordpress site
- Why is wp-login trying to send an email?
- Replacing default display name to login name
- Why does is_user_logged_in() return false after I change user password on the front end?
- How to generate “WP_Error” Object for user login?
- ?login=failed only attached to URL under certain circumstances
- How to order users by a date in the meta_value array
- Can I Get User ID at Login?
- WordPress not logged in locally with correct username and password
- my wp-login page doesn’t load [closed]
- Requiring login for specific pages
- login trouble WordPress can change IDs created by hoster site
- Exclude specific user_id from args in get_comments
- login/logout for only one page
- WordPress registration page template
- Removing “public” user registration without completely turning it off?
- Custom login modal page action
- Array of user ids to list of user names
- Require re-login when logged-in user attempts to access restricted page
- Disable registration on certain condition
- Temporally disable password to login with empty password?
- Reset Password Limit not working
- Login error when username as email different to primary email
- Unable to login my wordpress website
- How do you implement a login feature on a WordPress site?
- Help! ERROR: Cookies are blocked due to unexpected output on attempting to login to resolve an issue with my site
- Get user count based on multiple meta key values?
- How to log into WordPress admin in MAMP
- Special link for no automatic login (no username and no password)
- Can’t login with any account – No error message shown
- wp login password reset
- Cookies error during first time login attempt
- Making sure two different wordpress website has auto login
- How can get all users by current user meta (array)?
- Hide login page and use wp_login_form on ordinary pages
- Login screen keeps resetting?
- How to display checkbox meta array values one by one?
- How can I customize the content of the login page?
- WordPress giving error when I log in after trying emergency.php
- Some crawlers/bots attempting to login with very good guesses. How?
- Create custom field for users to check if they agreed to terms
- WordPress logs out on protocol switch
- Improvements to “limit login attempts” plugin
- Can’t login through wp-login.php on fresh installation
- Showing A Menu When Only Users Are Logged In [duplicate]
- wp_logout logging everyone out instead of just the user that clicked the logout link!
- Using wp_login_form passowrd as undefined
- Why doesn’t the “Remember Me” checkbox work for me on a live website? Only works on a local server environment
- Secure login without SSL? [closed]
- Cant login, Password MUST be reset error, after reset
- Trying to create a log in system but getting error “Parse error: syntax error, unexpected ‘else’ (T_ELSE) ” [closed]
- authenticate to another site using a login form on my site
- “user not registered” when trying to login and “There has been a critical error” message on site