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

Breadcrumb

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

function AccountProxy::hasRole

Whether a user has a certain role.

@todo in Drupal 11, add method to Drupal\Core\Session\AccountInterface.

Parameters

string $rid: The role ID to check.

Return value

bool Returns TRUE if the user has the role, otherwise FALSE.

See also

https://www.drupal.org/node/3228209

File

core/lib/Drupal/Core/Session/AccountProxy.php, line 113

Class

AccountProxy
A proxied implementation of AccountInterface.

Namespace

Drupal\Core\Session

Code

public function hasRole(string $rid) : bool {
    return $this->getAccount()
        ->hasRole($rid);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal