Skip to main content
Tweeted twitter.com/StackDrupal/status/850432685029957635
added 4 characters in body
Source Link

I need to get permissions for all user roles, which are used. The code looks something like this:

$anonymous = Role::load('anonymous');
$anonymousPermissions = $anonymous->getPermissions();

The code for anonymous (and also for authenticated) returns an array of permissions, but the same code for administrator returns null:

$administrator = Role::load('administrator');

How can I get permissions for the role Administrator? (The machine name of role Administrator is administrator and also in the database is nothing suspicious.)


I have tried also:

$anonymousPermissions$administratorPermissions = user_role_permissions(['administrator']);

It returns:

array(1) {
    ["administrator"] =>
        array(0) {
    }
}

If I try:

$roles = Role::loadMultiple();
foreach ($roles as $role => $rolesObj) {
    $role_list[$role] = $rolesObj->get('label');
}
print_r($role_list);

Then I get:

Array
(
    [anonymous] => Anonymous user
    [authenticated] => Authenticated user
)

I need to get permissions for all user roles, which are used. The code looks something like this:

$anonymous = Role::load('anonymous');
$anonymousPermissions = $anonymous->getPermissions();

The code for anonymous (and also for authenticated) returns an array of permissions, but the same code for administrator returns null:

$administrator = Role::load('administrator');

How can I get permissions for the role Administrator? (The machine name of role Administrator is administrator and also in the database is nothing suspicious.)


I have tried also:

$anonymousPermissions = user_role_permissions(['administrator']);

It returns:

array(1) {
    ["administrator"] =>
        array(0) {
    }
}

If I try:

$roles = Role::loadMultiple();
foreach ($roles as $role => $rolesObj) {
    $role_list[$role] = $rolesObj->get('label');
}
print_r($role_list);

Then I get:

Array
(
    [anonymous] => Anonymous user
    [authenticated] => Authenticated user
)

I need to get permissions for all user roles, which are used. The code looks something like this:

$anonymous = Role::load('anonymous');
$anonymousPermissions = $anonymous->getPermissions();

The code for anonymous (and also for authenticated) returns an array of permissions, but the same code for administrator returns null:

$administrator = Role::load('administrator');

How can I get permissions for the role Administrator? (The machine name of role Administrator is administrator and also in the database is nothing suspicious.)


I have tried also:

$administratorPermissions = user_role_permissions(['administrator']);

It returns:

array(1) {
    ["administrator"] =>
        array(0) {
    }
}

If I try:

$roles = Role::loadMultiple();
foreach ($roles as $role => $rolesObj) {
    $role_list[$role] = $rolesObj->get('label');
}
print_r($role_list);

Then I get:

Array
(
    [anonymous] => Anonymous user
    [authenticated] => Authenticated user
)
edited title
Link
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133

How to get user permissions for the role Administrator?

added 326 characters in body
Source Link

I need to get permissions for all user roles, which are used. The code looks something like this:

$anonymous = Role::load('anonymous');
$anonymousPermissions = $anonymous->getPermissions();

The code for anonymous (and also for authenticated) returns an array of permissions, but the same code for administrator returns null:

$administrator = Role::load('administrator');

How can I get permissions for the role Administrator? (The machine name of role Administrator is administrator and also in the database is nothing suspicious.)


I have tried also:

$anonymousPermissions = user_role_permissions(['administrator']);

It returns:

array(1) {
    ["administrator"] =>
        array(0) {
    }
}

If I try:

$roles = Role::loadMultiple();
foreach ($roles as $role => $rolesObj) {
    $role_list[$role] = $rolesObj->get('label');
}
print_r($role_list);

Then I get:

Array
(
    [anonymous] => Anonymous user
    [authenticated] => Authenticated user
)

I need to get permissions for all user roles, which are used. The code looks something like this:

$anonymous = Role::load('anonymous');
$anonymousPermissions = $anonymous->getPermissions();

The code for anonymous (and also for authenticated) returns an array of permissions, but the same code for administrator returns null:

$administrator = Role::load('administrator');

How can I get permissions for the role Administrator? (The machine name of role Administrator is administrator and also in the database is nothing suspicious.)


I have tried also:

$anonymousPermissions = user_role_permissions(['administrator']);

It returns:

array(1) {
    ["administrator"] =>
        array(0) {
    }
}

I need to get permissions for all user roles, which are used. The code looks something like this:

$anonymous = Role::load('anonymous');
$anonymousPermissions = $anonymous->getPermissions();

The code for anonymous (and also for authenticated) returns an array of permissions, but the same code for administrator returns null:

$administrator = Role::load('administrator');

How can I get permissions for the role Administrator? (The machine name of role Administrator is administrator and also in the database is nothing suspicious.)


I have tried also:

$anonymousPermissions = user_role_permissions(['administrator']);

It returns:

array(1) {
    ["administrator"] =>
        array(0) {
    }
}

If I try:

$roles = Role::loadMultiple();
foreach ($roles as $role => $rolesObj) {
    $role_list[$role] = $rolesObj->get('label');
}
print_r($role_list);

Then I get:

Array
(
    [anonymous] => Anonymous user
    [authenticated] => Authenticated user
)
added 216 characters in body
Source Link
Loading
Source Link
Loading