You are here

function create_user_permission_menu_alter in Create user permission 7

Implements hook_menu_alter().

Alters the 'admin/people/create' menu item: Replaces the access argument with a custom access callback function that is declared below.

File

./create_user_permission.module, line 18
The create user permission module.

Code

function create_user_permission_menu_alter(&$items) {

  // The original hook, function user_menu(), is setting access argument
  // 'administer users' to this menu item.
  // Although the 'access arguments' element is an array:
  // @see https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7.x
  // it can only contain one element:
  // @see https://www.drupal.org/forum/support/module-development-and-code-questions/2008-10-30/hook_menu-and-multiple-access
  // @see https://www.drupal.org/node/368584
  // Here the 'access argument' is getting unset, and instead an explicit
  // 'access callback' function will be used. The unset 'administer users' will
  // be checked into that function.
  unset($items['admin/people/create']['access arguments']);
  $items['admin/people/create']['access callback'] = 'create_user_permission_access_callback';
}