十年網(wǎng)站開(kāi)發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶(hù) + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專(zhuān)業(yè)推廣+無(wú)憂(yōu)售后,網(wǎng)站問(wèn)題一站解決
創(chuàng)新互聯(lián)www.cdcxhl.cn八線(xiàn)動(dòng)態(tài)BGP香港云服務(wù)器提供商,新人活動(dòng)買(mǎi)多久送多久,劃算不套路!
這篇文章主要介紹WordPress前臺(tái)顯示登錄用戶(hù)最后登錄時(shí)間的方法,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
可以將下面的代碼添加到當(dāng)前主題functions.php中:
// 記錄登錄時(shí)間 function user_last_login($user_login) { global $user_ID; // 糾正8小時(shí)時(shí)差 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')); } add_action('wp_login','user_last_login'); // 調(diào)用最后登錄時(shí)間 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; }
在主題模板適當(dāng)位置添加調(diào)用代碼:
ID); ?>
如果想在后臺(tái)用戶(hù)列表中顯示最后登錄時(shí)間可以安裝插件:WP Last Login 。
以上是WordPress前臺(tái)顯示登錄用戶(hù)最后登錄時(shí)間的方法的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道!