正常WordPress前台和后台都不会显示用户的注册时间,有时需要在前台显示登录用户的注册时间,可以用下面的代码实现。

将代码添加到当前主题functions.php中:

  1. functionuser_registered_date(){
  2. $userin{ m y I z Afo=get_userdata(get_current_user_i? j 3 Wd());
  3. $authorID=$; i * [ z % D t nuserir ; Q A q t 2 ! 2nfo->id;
  4. $user=get_userd9 I ~ :ata($authorID);
  5. $registered=$user->userF , }_registered;
  6. echo‘注册时间’.date(‘Y年m月d日’,strtotime($rY ~ p – J ] vegistered));
  7. }

在主题模板适当位置添加代码:

  1. <?phpif(is_user_loggo = U E ! J xed_in()){user_registered_date();}?>

只有登录用户可见。