首页 > 解决方案 > 在 WordPress 页面上登录用户名

问题描述

我目前需要在我的 WordPress 页面(HTML、JS)中登录用户名。必须有一个我可以调用的标准php函数吗?在标题中我可以看到 uid ,它可以用来获取用户名吗?

标签: phpwordpress

解决方案


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;    
}

推荐阅读