如何获取WordPress当前用户信息

在WordPress开发过程中,我们可能需要获取当前登录的用户信息

get-current-user-information-wpdaxue_com
可以参考下面的代码:

<?php global $current_user;
 get_currentuserinfo();
 echo '用户名: ' . $current_user->user_login . "\n";
 echo '用户邮箱: ' . $current_user->user_email . "\n";
 echo '名字: ' . $current_user->user_firstname . "\n";
 echo '姓氏: ' . $current_user->user_lastname . "\n";
 echo '公开显示名: ' . $current_user->display_name . "\n";
 echo '用户 ID:' . $current_user->ID . "\n";
?>

来源:

https://www.wpdaxue.com/get-current-user-information.html

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?