I need to create a permission that allows any user to create other users without allowing them to manage all users (ie without granting them 'administer users' permission).
My approach was altering menu 'admin/people/create' but it - for unknown reason - doesn't work. Even though the permission for the menu is granted the menu item with link for is invisible and when I go to the specific url it - if I don't have 'administer users' permission - just redirects me to current user profile page.
/**
* Implements hook_menu_alter().
*/
function fm_users_more_menu_alter(&$items) {
$add_new_user = &$items['admin/people/create'];
unset($add_new_user['access callback']);
unset($add_new_user['access arguments']);
$add_new_user['access callback'] = 'fmu_add_user_access_callback';
$add_new_user['access arguments'] = array(1);
}
/**
* Callback that manages access to create user page.
*/
function fmu_add_user_access_callback($arguement) {
dsm('test23');
return true;
}
It does the same - redirects you to current user profile page - with User register form.
$register_new_user = &$items['user/register'];
unset($register_new_user['access callback']);
$register_new_user['access callback'] = 'fmu_register_user_access_callback';
/**
* Callback that manages access to create user page.
*/
function fmu_register_user_access_callback() {
dsm('test23');
if (user_register_access() || user_access('create users under self')) {
return true;
}
else {
return false;
}
}