0

I am using Drupal 7.26, and I need a second administrator user. I created a user who can see the authenticated user's menu, but not the management menu which I (as user #1) can see.

How can I fix this? I want the user I created with administrator role to have access to everything from the management menu.

0

2 Answers 2

0

The page under admin require the access administration pages permission, or the administer themes one. (See system_menu(), the 'access arguments' lines.)

  $items['admin'] = array(
    'title' => 'Administration',
    'access arguments' => array('access administration pages'),
    'page callback' => 'system_admin_menu_block_page',
    'weight' => 9,
    'menu_name' => 'management',
    'file' => 'system.admin.inc',
  );
  $items['admin/compact'] = array(
    'title' => 'Compact mode',
    'page callback' => 'system_admin_compact_page',
    'access arguments' => array('access administration pages'),
    'type' => MENU_CALLBACK,
    'file' => 'system.admin.inc',
  );
  $items['admin/tasks'] = array(
    'title' => 'Tasks',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -20,
  );
  $items['admin/index'] = array(
    'title' => 'Index',
    'page callback' => 'system_admin_index',
    'access arguments' => array('access administration pages'),
    'type' => MENU_LOCAL_TASK,
    'weight' => -18,
    'file' => 'system.admin.inc',
  );

  // Menu items that are basically just menu blocks.
  $items['admin/structure'] = array(
    'title' => 'Structure',
    'description' => 'Administer blocks, content types, menus, etc.',
    'position' => 'right',
    'weight' => -8,
    'page callback' => 'system_admin_menu_block_page',
    'access arguments' => array('access administration pages'),
    'file' => 'system.admin.inc',
  );
  // Appearance.
  $items['admin/appearance'] = array(
    'title' => 'Appearance',
    'description' => 'Select and configure your themes.',
    'page callback' => 'system_themes_page',
    'access arguments' => array('administer themes'),
    'position' => 'left',
    'weight' => -6,
    'file' => 'system.admin.inc',
  );

The user you create must have a role with the right permission. Go to admin/people/permissions and assign to the role of that use the necessary permissions, listed under System.

screenshot

Keep in mind that the user #1 has every permission, independently from the roles it has. If you are wondering why there is a difference between the user you created and the user you normally use, even if they have the same role, that is the reason. Drupal check the currently logged-in user is the user #1, as visible in the code for user_access().

  // User #1 has all privileges:
  if ($account->uid == 1) {
    return TRUE;
  }

User #1 could not have any extra role, and simply be an authenticated user, and still it would have all the permissions, contrary to the normal authenticated users, who have just the permissions you assign to the authenticated user role.

1
  • I completed the code to user_access() and it worked...thank you... Jun 10, 2016 at 13:55
0

1.I found from the database and from table "users" the uid that belongs to the user i want to be an administrator. 2.I found the file user.module here: mysite/modules/user/user.module 3. I changed the following code : // User #1 has all privileges: if ($account->uid == 1 || $account->uid == my_uid ) { return TRUE; } and it's worked.

1
  • 1
    Are you sure your solution will continue to work next time user.module gets updated? Jun 10, 2016 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.