function UserInterface::hasRole

Same name in other branches
  1. 9 core/modules/user/src/UserInterface.php \Drupal\user\UserInterface::hasRole()
  2. 8.9.x core/modules/user/src/UserInterface.php \Drupal\user\UserInterface::hasRole()
  3. 10 core/modules/user/src/UserInterface.php \Drupal\user\UserInterface::hasRole()

Whether a user has a certain role.

@todo in Drupal 11, move 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

1 method overrides UserInterface::hasRole()
User::hasRole in core/modules/user/src/Entity/User.php
Whether a user has a certain role.

File

core/modules/user/src/UserInterface.php, line 65

Class

UserInterface
Provides an interface defining a user entity.

Namespace

Drupal\user

Code

public function hasRole($rid);

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