function AccountInterface::hasRole

Same name and namespace in other branches
  1. main core/lib/Drupal/Core/Session/AccountInterface.php \Drupal\Core\Session\AccountInterface::hasRole()

Whether a user has a certain role.

Parameters

string $rid: The role ID to check.

Return value

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

3 methods override AccountInterface::hasRole()
AccountProxy::hasRole in core/lib/Drupal/Core/Session/AccountProxy.php
Whether a user has a certain role.
User::hasRole in core/modules/user/src/Entity/User.php
Whether a user has a certain role.
UserSession::hasRole in core/lib/Drupal/Core/Session/UserSession.php
Whether a user has a certain role.

File

core/lib/Drupal/Core/Session/AccountInterface.php, line 65

Class

AccountInterface
Defines an account interface which represents the current user.

Namespace

Drupal\Core\Session

Code

public function hasRole(string $rid);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.