1 user.module user_role_permissions($role_names = array())

Determine the permissions for one or more roles.

Parameters

$role_names: An unindexed array of role names, such as those in $user->roles.

Return value

An array of permission strings for all the given role names.:

File

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

Code

function user_role_permissions($role_names = array()) {
  $all_roles = user_roles(FALSE, NULL, TRUE);
  $role_permissions = array();
  foreach ($role_names as $role_name) {
    if (isset($all_roles[$role_name])) {
      foreach ($all_roles[$role_name]->permissions as $permission) {
        if (!in_array($permission, $role_permissions)) {
          $role_permissions[] = $permission;
        }
      }
    }
  }

  return $role_permissions;
}