1 user.module user_role_grant_permissions($role_name, array $permissions = array())

Grant permissions to a user role.

Parameters

string $role_name: The name of a user role to alter.

array $permissions: A list of permission names to grant.

See also

user_role_change_permissions()

user_role_revoke_permissions()

File

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

Code

function user_role_grant_permissions($role_name, array $permissions = array()) {
  $user_role = user_role_load($role_name);
  $user_role->permissions = array_values(array_unique(array_merge($user_role->permissions, $permissions)));
  user_role_save($user_role);
}