You are here

function user_role_revoke_permissions in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/user/user.module \user_role_revoke_permissions()
  2. 7 modules/user/user.module \user_role_revoke_permissions()
  3. 9 core/modules/user/user.module \user_role_revoke_permissions()

Revoke permissions from a user role.

Parameters

mixed $rid: The ID of a user role to alter.

array $permissions: (optional) A list of permission names to revoke.

See also

user_role_change_permissions()

user_role_grant_permissions()

12 calls to user_role_revoke_permissions()
CommentAnonymousTest::testAnonymous in core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
Tests anonymous comment functionality.
CommentBlockTest::testRecentCommentBlock in core/modules/comment/tests/src/Functional/CommentBlockTest.php
Tests the recent comments block.
ContactPersonalTest::testPersonalContactAccess in core/modules/contact/tests/src/Functional/ContactPersonalTest.php
Tests access to the personal contact form.
ContactSitewideTest::testSiteWideContact in core/modules/contact/tests/src/Functional/ContactSitewideTest.php
Tests configuration options and the site-wide contact form.
FileFieldWidgetTest::testPrivateFileComment in core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
Tests that download restrictions on private files work on comments.

... See full list

File

core/modules/user/user.module, line 992
Enables the user registration and login system.

Code

function user_role_revoke_permissions($rid, array $permissions = []) {

  // Revoke permissions for the role.
  $role = Role::load($rid);
  foreach ($permissions as $permission) {
    $role
      ->revokePermission($permission);
  }
  $role
    ->trustData()
    ->save();
}