user_role_grant_permissions

Versions
7
user_role_grant_permissions($rid, array $permissions = array())

Grant permissions to a user role.

See also

user_role_change_permissions()

@see user_role_revoke_permissions()

Parameters

$rid The ID of a user role to alter.

$permissions A list of permission names to grant.

▾ 6 functions call user_role_grant_permissions()

contact_update_7002 in modules/contact/contact.install
Enable the 'access user contact forms' for registered users by default.
default_install in profiles/default/default.install
Implement hook_install().
expert_install in profiles/expert/expert.install
Implement hook_install().
filter_update_7005 in modules/filter/filter.install
Integrate text formats with the user permissions system.
node_update_7008 in modules/node/node.install
Split the 'administer nodes' permission from 'access content overview'.
user_role_change_permissions in modules/user/user.module
Change permissions for a user role.

Code

modules/user/user.module, line 2494

<?php
function user_role_grant_permissions($rid, array $permissions = array()) {
  // Grant new permissions for the role.
  foreach ($permissions as $name) {
    db_merge('role_permission')
      ->key(array(
        'rid' => $rid,
        'permission' => $name,
      ))
      ->execute();
  }

  // Clear the user access cache.
  drupal_static_reset('user_access');
  drupal_static_reset('user_role_permissions');
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.