function user_role_revoke_permissions

Same name in other branches
  1. 7.x 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. 11.x 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()

11 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 1025

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();
}

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