Getting submenu items to appear within the user edit area of Drupal has not always worked as I would expect from reading the documentation around hook_menu(). As it happens the user module provides hooks to make this quite simple.
In this example we would have a new set of tabs added to the User Edit page. The first is Account and is now presented because we have more than one tab here now. The second is Report Settings and it would have a URL like
user/12345/edit/report_settings where report_settings is taken from the name parameter.
At this point we have a new menu item presented as a tab on the user edit page and clicking it takes us to a blank form with a submit button. I think this is due to the way menu items can inherit behaviour from parent menu items. We’ll be wanting to overload that behaviour though and present our own form. This can be done through hook_menu_alter().
Checking the keys of the array passed to hook_menu_alter() we should find that we have a new one called
user/%user_category/edit/report_settings. We can edit this one to point it at our preferred form built using the Form API as usual.
- You will want to be clearing your menu cache a lot while getting this working. Every edit will require a
drush cc menu.
- Ensure you have set the
file pathin the hook_menu_alter() if you have your have your page callback or form function for drupal_get_form() in a separate file.