public function User::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.

Overrides UserInterface::hasRole

File

drupal/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php, line 278
Definition of Drupal\user\Plugin\Core\Entity\User.

Class

User
Defines the user entity class.

Namespace

Drupal\user\Plugin\Core\Entity

Code

public function hasRole($rid) {
  return in_array($rid, $this
    ->getRoles());
}