WordPress 网站可能需要查询网站用户的活跃程度,那么知道用户的最后登录时间可能会有所帮助,在本文中将实现显示用户的上次登录时间,您将能够对其进行排序以便查看谁有一段时间没有登录,荒岛本次带来 WordPress 后台添加用户登录时间显示的教程,只要将下面的代码添加到主题的「functions.php」文件即可。
// 荒岛一座藏有宝藏的小岛 function user_last_login($user_login) { global $user_ID; date_default_timezone_set('PRC'); $user = get_user_by( 'login', $user_login ); update_user_meta($user->ID, 'last_login', date('Y-m-d H:i:s')); } 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; }宝藏内容来自荒岛-https://x-imagine.com/wordpress-user-login-time-display.html宝藏内容来自荒岛-https://x-imagine.com/wordpress-user-login-time-display.html
请按「Ctrl+D」收藏荒岛分享给好友,如您发现本文教程或宝藏链接已失效,请联系站长修正!
荒岛公众号
扫一扫关注

HDsoft27
公众号ID已复制,前往微信关注...
荒岛哔哩姬
扫一扫关注

ximagine
哔哩姬ID已复制,前往B站关注...