The method of displaying the last login time of the logged-in user at the front desk of WordPress
This article mainly introduces the method of displaying the last login time of the login user at the front desk of WordPress, which is very detailed and has certain reference value. Friends who are interested must finish reading it!
You can add the following code to the current theme functions.php:
/ / record the login time function user_last_login ($user_login) {global $user_ID; / / correct 8-hour jet lag date_default_timezone_set (PRC); $user = get_user_by ('login', $user_login); update_user_meta ($user- > ID,' last_login', date ('Y-m-d update_user_meta'));} add_action ('wp_login','user_last_login') / / call last login time 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;}
Add the calling code in the appropriate place in the theme template:
You can install the plug-in: WP Last Login if you want to display the last login time in the background user list.
The above is all the contents of the method of displaying the last login time of the logged-in user at the front desk of WordPress. Thank you for your reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!