function user_role_grant_permissions
user_role_grant_permissions($rid, array $permissions = array())
Grant permissions to a user role.
Parameters
$rid: The ID of a user role to alter.
$permissions: A list of permission names to grant.
See also
user_role_change_permissions()
user_role_revoke_permissions()
File
- modules/user/user.module, line 3161
- Enables the user registration and login system.
Code
function user_role_grant_permissions($rid, array $permissions = array()) { $modules = user_permission_get_modules(); // Grant new permissions for the role. foreach ($permissions as $name) { db_merge('role_permission') ->key(array( 'rid' => $rid, 'permission' => $name, )) ->fields(array( 'module' => $modules[$name], )) ->execute(); } // Clear the user access cache. drupal_static_reset('user_access'); drupal_static_reset('user_role_permissions'); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!user!user.module/function/user_role_grant_permissions/7.x