php - 在 WordPress 页面上登录用户名
问题描述
我目前需要在我的 WordPress 页面(HTML、JS)中登录用户名。必须有一个我可以调用的标准php函数吗?在标题中我可以看到 uid ,它可以用来获取用户名吗?
解决方案
You can try the following peice of code to print the firstname of loggedin user.
if ( is_user_logged_in() )
{
global $current_user;
get_currentuserinfo();
echo $current_user->user_firstname;
}
推荐阅读
- python-3.x - 使用 selenium 的 Python 网络爬虫
- python - 如何在元组列表中查找部分字符串匹配
- javascript - 如何在 JS 中正确创建动态表?
- google-sheets - 无法计算 X 和 Y 为真的出现次数
- big-o - 关于算法复杂度的表达式
- javascript - 按名称从数组中删除项目
- javascript - 如何通过在 json 配置“键”上迭代现有数组来创建新数组?
- datetime - 如何在 Kotlin 标准库(多平台)上获取当前的 unixtime
- php - 在 Wordpress 登录后将特定用户角色重定向到特定位置
- applescript - AppleScript 移动鼠标并单击 Photoshop 中的特定元素