Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of displaying the last login time of the logged-in user at the front desk of WordPress

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report