如何获取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";
?>
发布了1997 篇原创文章 · 获赞 507 · 访问量 252万+

猜你喜欢

转载自blog.csdn.net/mp624183768/article/details/103636966