function user_role_revoke_permissions

Same name and namespace in other branches
  1. 10 core/modules/user/user.module \user_role_revoke_permissions()
  2. 9 core/modules/user/user.module \user_role_revoke_permissions()
  3. 8.9.x core/modules/user/user.module \user_role_revoke_permissions()
  4. 7.x modules/user/user.module \user_role_revoke_permissions()
  5. main 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.

Deprecated

in drupal:11.5.0 and is removed from drupal:13.0.0. Use \Drupal\user\RoleInterface::revokePermissions() instead.

See also

RoleInterface::changePermissions()

RoleInterface::grantPermissions()

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

3 calls to user_role_revoke_permissions()
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.
SettingsTrayBlockFormTest::doTestBlocks in core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
Tests opening off-canvas dialog by click blocks and elements in the blocks.

File

core/modules/user/user.module, line 449

Code

function user_role_revoke_permissions($rid, array $permissions = []) : void {
  @trigger_error(__METHOD__ . '() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Use \\Drupal\\user\\RoleInterface::revokePermissions() instead. See https://www.drupal.org/node/3348027', E_USER_DEPRECATED);
  $role_storage = \Drupal::entityTypeManager()->getStorage('user_role');
  $role = $role_storage->loadOverrideFree($rid);
  $role->revokePermissions($permissions);
  $role->save();
}

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