Skip to content

Instantly share code, notes, and snippets.

@malachi358
Created July 12, 2014 18:15
Show Gist options
  • Save malachi358/8de1e42ae4bbdffaeb32 to your computer and use it in GitHub Desktop.
Save malachi358/8de1e42ae4bbdffaeb32 to your computer and use it in GitHub Desktop.
WP User Information
<?php
$current_user = wp_get_current_user();
/**
* @example Safe usage: $current_user = wp_get_current_user();
* if ( !($current_user instanceof WP_User) )
* return;
*/
echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $current_user->user_email . '<br />';
echo 'User first name: ' . $current_user->user_firstname . '<br />';
echo 'User last name: ' . $current_user->user_lastname . '<br />';
echo 'User display name: ' . $current_user->display_name . '<br />';
echo 'User ID: ' . $current_user->ID . '<br />';
?>
/**--------------------------------------------------------------------*/
<?php
$current_user = wp_get_current_user();
if ( 0 == $current_user->ID ) {
// Not logged in.
} else {
// Logged in.
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment