1

I am using Drupal 6 with the OpenAtrium distribution, and I'd like to completely remove the account settings menu. In other words, I don't want users (or, even better, certain users) from access account settings. I know that it can be done by hiding the menu via CSS, but I am looking for some kind of module that can make it easier.

EDIT:

Ok what I did was creating and activating a new module called disablepermissions:

function disablepermissions_menu_alter(&$items){
     $items['user']['access callback'] = FALSE;
     $items['user/%user/edit']['access callback'] = FALSE;
     $items['user/%user']['access callback'] = FALSE;
}

This actually works as intended but if I try to set some kind of permissions I only get a blank page with a 500 Internal Server Error, why? The following code does not work...

function disablepermissions_perm() {
    return array('visualizza utenti');
}

function disablepermissions_menu_alter(&$items){
     if (access_user('visualizza utenti') {
     $items['user']['access callback'] = TRUE;
     $items['user/%user/edit']['access callback'] = TRUE;
     $items['user/%user']['access callback'] = TRUE;
     }
     else {
     $items['user']['access callback'] = FALSE;
     $items['user/%user/edit']['access callback'] = FALSE;
     $items['user/%user']['access callback'] = FALSE;
     }
}
  • To which account settings are you referring? What is the URL of that setting page? – kiamlaluno Nov 13 '12 at 15:40
  • /user/n/edit where n is the id of the user ofcourse. – raz3r Nov 13 '12 at 16:18
1

You could use hook_menu_alter(). Something like this should work:

function yourmodule_menu_alter(&$items){
  $items['user/%user_category/edit']['access callback'] = 'yourmodule_user_custom_access_function';
}

function yourmodule_user_custom_access_function($u){
  return user_access('administer users');
}

This way, only users with "administer users" permissions will be able to edit user informations.

| improve this answer | |
  • I am not really into Drupal that much. Let's say I add this code to an existing module who will call the subroutine? I'd like to understand how things work before changing code. – raz3r Nov 14 '12 at 7:51
  • Ok what I did was creating a custom module with the code you provided. I activated the module, cleared cache but nothing has changed :( – raz3r Nov 14 '12 at 8:02
  • Uhm... Do I have to install additional modules in order to access hook_menu_alter()? Because I see it is part of core.php under /development/hook folder but I don't have that folder on my system at all. – raz3r Nov 14 '12 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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