正常WordPress前台和后台都不会显示用户的注册时间,有时需要在前台显示登录用户的注册时间,可以用下面的代码实现。
将代码添加到当前主题functions.php中:
- functionuser_registered_date(){
- $userin{ m y I z Afo=get_userdata(get_current_user_i? j 3 Wd());
- $authorID=$; i * [ z % D t nuserir ; Q A q t 2 ! 2nfo->id;
- $user=get_userd9 I ~ :ata($authorID);
- $registered=$user->userF , }_registered;
- echo‘注册时间’.date(‘Y年m月d日’,strtotime($rY ~ p – J ] vegistered));
- }
在主题模板适当位置添加代码:
- <?phpif(is_user_loggo = U E ! J xed_in()){user_registered_date();}?>
只有登录用户可见。
原创文章,作者:帝道,如若转载,请注明出处:https://www.6fzz.com/4221.html