I have fetched some problem with user modules. When I go to this path "admin/user/user" to manage user I see there's a button "Add user". For some reason I don't want to have this button. I want to delete this button. I have tried and modified the user module. I know where the button code is. It's on user.module file at line 975 the code is as bellow:

$items['admin/user/user/create'] = array(
'title' => 'Add user',
'page arguments' => array('create'),
'access arguments' => array('administer users'),
'type' => MENU_LOCAL_TASK,
'file' => 'user.admin.inc',
);

I have delete this code but the button still remain. Any one can help me to delete this button?

Thanks

[This problem has been solved by "callison". I thanked him again.]

Comments

jaypan’s picture

Show us your code.

Contact me to contract me for D7 -> D10/11 migrations.

mdibrahim’s picture

I have already shown here. Actually I just delete this code from the module file but it's not working.

jaypan’s picture

That's a REALLY bad way to do it. Anytime you update Drupal, it will overwrite your changes. You should use the hook_ _alter functions to unset the element you don't want to display.

Contact me to contract me for D7 -> D10/11 migrations.

mdibrahim’s picture

Yes I have been tried but not succeed.

yelvington’s picture

Begin by looking at this slide from a Drupal conference:

http://heyrocker.com/hack_core.jpg

Then read this:

http://api.drupal.org/api/function/hook_menu_alter/6

mdibrahim’s picture

I have tried with this code:

function user_menu_alter(&$items) {
// Example - disable the page at node/add
$items['admin/user/user/create']['access callback'] = FALSE;
}

but the "Add user" button still appears. I can't remove it.

rightchoice2c_me’s picture

it will be in user.module in hook_menu(); around line number 961.
once u remove that code u need to rebiuld menus, u can just resave themes configurations.

BTW, its not a good practise to edit core file, u can override the theming function or u can use hook_form_alter to remove add user link.

mdibrahim’s picture

Yes I tried accordingly to said still the same result. So I finally understood. Changing the core modules it's not really easy or effective.

Thanks for spending your time for me.

callison’s picture

By the time I finished my comment, others had already posted. What I wrote below works - hope it helps.

callison’s picture

The 'Add User' button is actually a tab, so check out this page: http://drupal.org/node/68792

This will do the trick if you put the following code in your theme's template.php file:

Note: Please replace each use of THEME below with your current theme's name (lowercase).

function THEME_preprocess_page(&$vars) {
  // Remove undesired local task tabs.
  // This first example removes the Users tab from the Search page.
  my_removetab('Add user', $vars);
}

// Remove undesired local task tabs.
// Related to yourthemename_removetab() in yourthemename_preprocess_page().
function THEME_removetab($label, &$vars) {
  $tabs = explode("\n", $vars['tabs']);
  $vars['tabs'] = '';

  foreach ($tabs as $tab) {
    if (strpos($tab, '>' . $label . '<') === FALSE) {
      $vars['tabs'] .= $tab . "\n";
    }
  }
}
mdibrahim’s picture

Thank you very much. Now it's working. So finally I found out the problem. Actually it's on template files.

Thank you very much.

callison’s picture

You're welcome. Glad to be helpful.