您的当前位置:首页 > 知识博客 > wordpress建站

WordPress获取登录用户信息函数:get_currentuserinfo

时间:2024-03-09

WordPress函数get_currentuserinfo用于获取当前登录用户信息,自4.5.0版本起,已不建议使用get_currentuserinfo,请换用wp_get_current_user()函数。

函数返回值

get_currentuserinfo()函数返回WP_User实例,包含了用户的各字段信息。

函数使用示例

$userinfo = get_currentuserinfo();
echo '用户名:' . $userinfo->user_login . '<br >';
echo '邮箱:' . $userinfo->user_email . '<br >';
echo '名字:' . $userinfo->user_firstname . '<br >';
echo '姓氏:' . $userinfo->user_lastname . '<br >';
echo '公开显示名称:' . $userinfo->display_name . '<br >';
echo 'ID:' . $userinfo->ID . '<br >';

扩展阅读

get_currentuserinfo()函数位于:wp-includes/pluggable-deprecated.php

相关函数:

  • wp_get_current_user()


欢迎咨询/Welcome to inquire
tel/vx:18842938855
qq:1685522781
email:1685522781@qq.com

Copyright © 2019-2024 sex.cyou


Whatsapp
Powered by RRZCMS