Drupal 8 get user fields

\Drupal::currentUser() returns an Drupal\Core\Session\AccountInterface object. That could be a full user (that would be a Drupal\user\UserInterface), but right now, for the default authentication method, it is not.

Use this to get the user entity and all the fields:

$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());

Get current user's role.

$user = \Drupal::currentUser()->getRoles();

Some default getters include.

$email = $user->get('mail')->value;

$name = $user->get('name')->value; $uid= $user->get('uid')->value;

Sample blackbox block

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas non porta odio, id mattis erat.

Nam sed tincidunt eros. Donec a venenatis odio, vitae commodo sem. Vivamus ullamcorper pellentesque erat, in adipiscing tortor scelerisque sit amet. Nulla pulvinar urna magna. Vivamus a ipsum lorem. Etiam adipiscing pulvinar lorem.