user_role_grant_permissions($rid, array $permissions = array())
Grant permissions to a user role.
Parameters
mixed $rid: The ID of a user role to alter.
array $permissions: (optional) A list of permission names to grant.
See also
user_role_change_permissions()
user_role_revoke_permissions()
File
- core/modules/user/user.module, line 1139
- Enables the user registration and login system.
Code
1 2 3 4 5 6 7 8 9 | function user_role_grant_permissions( $rid , array $permissions = array ()) { // Grant new permissions for the role. if ( $role = Role::load( $rid )) { foreach ( $permissions as $permission ) { $role ->grantPermission( $permission ); } $role ->trustData()->save(); } } |
Please login to continue.