I have two roles, client & student. Students can edit their profiles, clients cannot. I thought the easiest way to solve this would be to add a permission as per below:

function si_permission() {
  return array(
    'edit account' => array(
    'title' => t('Edit account'),
    'description' => t('Allow users to edit their account')

I then altered the menu item and changed the access callback to my new permission:

function si_dashboard_menu_alter(&$items) {
  $items['user/%user/edit']['access callback'] = user_access('edit account');

I then set the permission appropriately in permissions settings, but it does not work. It always appears to be false, so the menu item access is always disabled. I have even debugged 'user_access('edit account')' whilst logged in as the appropriate user and it returns TRUE, so I know the permission is working.

All caches cleared, menus rebuilt using developer tools. Any ideas?

1 Answer 1


Ok, it appears I have to set the access as per following:

function si_dashboard_menu_alter(&$items) {
  $items['user/%user/edit']['access callback'] = 'user_access';
  $items['user/%user/edit']['access arguments'] = array('edit account');
  • 1
    Shouldn't that be array('edit account')? Note that this will mean users with the Administer users permission but without Edit account won't be able to edit any accounts. (Not necessarily a problem, but could be a surprise.)
    – Andy
    Jul 23, 2014 at 15:05
  • @Andy User 1 bypasses anything sent through user_access() so that won't be an issue - definitely should be an array, though
    – Clive
    Jul 23, 2014 at 15:06
  • Sorry, just re-read that and it's nonsense. Please ignore :)
    – Clive
    Jul 23, 2014 at 15:06
  • @Andy yes sorry missed that when I typed it up manually.
    – davewilly
    Jul 23, 2014 at 15:22

Your Answer

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

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