Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Drupal.php

function Drupal::currentUser

Gets the current active user.

This method will return the \Drupal\Core\Session\AccountProxy object of the current user. You can use the \Drupal\user\Entity\User::load() method to load the full user entity object. For example:

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

Return value

\Drupal\Core\Session\AccountProxyInterface

46 calls to Drupal::currentUser()
CommentFieldItemList::access in core/modules/comment/src/CommentFieldItemList.php
Checks data value access.
ContentModerationViewsExecutionHooks::viewsQuerySubstitutions in core/modules/content_moderation/src/Hook/ContentModerationViewsExecutionHooks.php
Implements hook_views_query_substitutions().
content_translation_translate_access in core/modules/content_translation/content_translation.module
Access callback for the translation overview page.
DisplayPluginBase::access in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Determines if the user has access to this display of the view.
EntityAccessControlHandler::prepareUser in core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
Loads the current account object, if it does not exist yet.

... See full list

File

core/lib/Drupal.php, line 304

Class

Drupal
Static Service Container wrapper.

Code

public static function currentUser() {
    return static::getContainer()->get('current_user');
}
RSS feed
Powered by Drupal