Hi Im trying to disable the tab all together from the users profile.

The reason is this:

Im using the module with permissions for the user to choose their own role.

I can go to other users profiles and edit their role - Regardless of if Im logged in as administrator or authenticated user - Not good!

Maybe you could add an extra permission to only change the role if it's your role?

Or

An option to toggle the tab on/off?

For now I will settle for just being able to hide/get rid of it - Any help or advice with this would be great.

Many thanks

Comments

Andrew Schulman’s picture

Assigned: Unassigned » Andrew Schulman
Category: support » feature
Pasqualle’s picture

Assigned: Andrew Schulman » Unassigned

to hide the tab you can implement hook_menu_alter():

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

to hide the tab for other users:

function mymodule_menu_alter(&$items) {
  $items['user/%user/roles']['access callback'] = 'mymodule_special_access';
  $items['user/%user/roles']['access arguments'] = array(1);
}

function mymodule_special_access($account) {
  if ($account->uid != $GLOBALS['user']->uid) {
    // Just self assignment is allowed.
    return FALSE;
  }

  // If the tab is for current user, then check the original access callback.
  return role_delegation_access();
}
Pasqualle’s picture

I guess we can create two types of permissions: "assign x role to anybody", "self assign x role", but I am not sure how useful would that be in general..

Taxoman’s picture

#3: those would be useful. +1

JeroenT’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

It’s been a while since the last comments in this issue. If this is still a problem feel free to reopen and provide patches.