Get logged in user info in wordpress

Get logged in user info in wordpress

Use wp_get_current_user() function to get logged in user info.  We can use wp_get_current_user() function without any argument. It will return an object, if user is logged in else return 0. We can check if user is logged in using function is_user_logged_in(). I'm using the following code to get logged in user.

    if ( is_user_logged_in() ) { 
        $getLoggedInUser = wp_get_current_user();
        echo '<pre>';

Hi, I'm Saurav, the developer behind usingphp. Donate to help me keep usingphp free and maintained.

Please let me know what your thoughts or comments are on this article. If you have any suggestion or found any mistake in this article then please let us know.

Latest Comments

Add your comment