wordpress get current user objet code example
Example 1: wordpress get username
$current_user = wp_get_current_user();
echo($current_user->user_login);
Example 2: wordpress get current user role
$user = wp_get_current_user();
if ( in_array( 'author', (array) $user->roles ) ) {
//The user has the "author" role
}