You are here

function uma_getUser in User Menu Avatar (User Image in Menu) 8.5

Same name and namespace in other branches
  1. 8.4 user_menu_avatar.module \uma_getUser()

Get the current user.

File

./user_menu_avatar.module, line 19
Display user picture and/or user name in menu.

Code

function uma_getUser() {

  // Get current user ID.
  $userID = \Drupal::currentUser()
    ->id();

  // Load the current user by user ID.
  $currentUser = User::load($userID);
  return [
    'user_id' => $userID,
    'currentUser' => $currentUser,
  ];
}