0

How can i add a new tab in user edit page. In user view page it is coming , but user edit page is not giving any result.

function usermail_menu() { 
$items = array();
$items['user/%/invoice'] = array(
    'type' => MENU_LOCAL_TASK,
    'title' => 'Subscription Invoice',
    'page callback' => 'usermail_invoice',
    'access callback' => 'user_is_logged_in',
    'weight' => 3 
);
return $items;
}

This is working correctly. For user edit page i changed the path as

function usermail_menu() { 
$items = array();
$items['user/%/edit/invoice'] = array(
    'type' => MENU_LOCAL_TASK,
    'title' => 'Subscription Invoice',
    'page callback' => 'usermail_invoice',
    'access callback' => 'user_is_logged_in',
    'weight' => 3 
);
return $items;
}

But it is not coming. Please help me. Do i want to add something else?

4
  • have you cleared cache? Jan 25, 2013 at 10:07
  • I dont think you need two menu items. you just need one. change it to user/%user/invoice Jan 25, 2013 at 10:10
  • yes, i tried that also.
    – praji
    Jan 25, 2013 at 10:11
  • i need only on the edit page. For testing i did it on view page
    – praji
    Jan 25, 2013 at 10:12

2 Answers 2

3

In user.module I saw

$items['user/%user/edit'] = array(
    'title' => 'Edit',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('user_profile_form', 1),
    'access callback' => 'user_edit_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'file' => 'user.pages.inc',
);

So user/%user/edit will be considered as a parent menu item.

Try this:


function usermail_menu() { 
  $items = array();
  $items['user/%/edit/invoice'] = array(
    'type' => MENU_LOCAL_ACTION,
    'title' => 'Subscription Invoice',
    'page callback' => 'usermail_invoice',
    'access callback' => 'user_is_logged_in',
    'weight' => 3,
  );

  return $items;
}

MENU_LOCAL_ACTION allows you to add actions on the parent item.

Clear menu cache after making changes.

2
  • I tried this also. But the tab is not at all appearing.
    – praji
    Jan 25, 2013 at 11:01
  • 2
    user/%user/edit is MENU_LOCAL_TASK so you can only add other menu items with MENU_LOCAL_ACTION in that, they will not appear as tab but as suggested actions in user edit page. I have also tested my code in a custom module and it is working ok Jan 25, 2013 at 11:36
3

You just need one item only. Please make the following change

$items['user/%user/invoice'] = array(
    'type' => MENU_LOCAL_TASK,
    'title' => 'Subscription Invoice',
    'page arguments' => array('user', 1),
    'page callback' => 'usermail_invoice',
    'access callback' => 'user_is_logged_in',
    'weight' => 3 
);
2
  • In view page it is already working. In user edit page only it is not coming.
    – praji
    Jan 25, 2013 at 10:30
  • By default it would come for both view and edit. if you want it only for edit then you would do what subhojit777 has explained. This would render the link below the edit view etc. tabs Jan 25, 2013 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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