简体   繁体   中英

Logged in Username on WordPress page

I need currently Logged in Username in my WordPress Page ( HTML, JS). There must a standard function of php that I can call? In header I can see uid , that can be used to fetch the username?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM