我一直試圖在我的網站上再次注冊用戶的注銷,但它似乎不再起作用了。
以下代碼是我現在正在處理的代碼
function user_last_logout(){
update_user_meta( get_current_user_id(), '_last_logout', time() );
}
add_action( 'wp_logout', 'user_last_logout', 10, 1 );
uj5u.com熱心網友回復:
get_current_user_id()在您的情況下回傳 0,因為您的函式是在注銷后呼叫的。
你可以這樣做
function user_last_logout($user_id){
update_user_meta( $user_id, '_last_logout', time() );
}
add_action( 'wp_logout', 'user_last_logout', 10, 1 );
當 wp_logout 傳遞注銷的用戶 ID 時。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/492282.html
上一篇:創建輸入向量和數字的函式
