WordPress tutorials: Get user info

Wpsnipp – Retrieves the information pertaining to the currently logged in user, and places it in the global variable $current_user. Properties map directly to the wp_users table in the database. Adding this PHP code to your wordpress theme will display the current users information.

 

 

<?php global $current_user;
get_currentuserinfo();
echo 'Username: ' . $current_user->user_login . "n";
echo 'User email: ' . $current_user->user_email . "n";
echo 'User first name: ' . $current_user->user_firstname . "n";
echo 'User last name: ' . $current_user->user_lastname . "n";
echo 'User display name: ' . $current_user->display_name . "n";
echo 'User ID: ' . $current_user->ID . "n";
?>

Leave a comment