php – Logged in Username on WordPress page-ThrowExceptions

Exception or error:

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?

How to solve:

You can try the following peice of code to print the firstname of loggedin user.

if ( is_user_logged_in() ) 
    global $current_user; 
    echo $current_user->user_firstname;    

Leave a Reply

Your email address will not be published. Required fields are marked *