| 7 user.api.php | hook_user_categories() |
Retrieve a list of user setting or profile information categories.
Return value
An array of associative arrays. Each inner array has elements:
- "name": The internal name of the category.
- "title": The human-readable, localized name of the category.
- "weight": An integer specifying the category's sort ordering.
- "access callback": Name of the access callback function to use to determine whether the user can edit the category. Defaults to using user_edit_access(). See hook_menu() for more information on access callbacks.
- "access arguments": Arguments for the access callback function. Defaults to array(1).
Related topics
2 functions implement hook_user_categories()
1 invocation of hook_user_categories()
File
- modules/
user/ user.api.php, line 200 - Hooks provided by the User module.
Code
function hook_user_categories() {
return array(array(
'name' => 'account',
'title' => t('Account settings'),
'weight' => 1,
));
}
Login or register to post comments
Comments
Code sample
The code sample can be seen at: http://blog.eood.cn/add-a-custom-tab-menu-in-profile-edit-page-in-drupal...
Example custom user category tab
<?php
/**
* hook_user_categories
*/
function example_user_categories(){
$output[] = array(
'name' => 'profile',
'title' => t('Profile'),
'weight' => 3,
'access callback' => 'user_access',
'access arguments' => array('edit own commerce_customer_profile entities of bundle profile_info'),
);
return $output;
}
?>
and then you need to define the additional properties in hook_menu_alter
<?php
/**
* hook_menu_alter
*/
function example_menu_alter(&$items){
// Need to add user category tabs here like this
// first in hook_user_categories, then here to expand
$items['user/%user_category/edit/profile']['page callback'] = 'example_customer_profile_form_wrapper';
$items['user/%user_category/edit/profile']['page arguments'] = array(1);
$items['user/%user_category/edit/profile']['module'] = 'example';
$items['user/%user_category/edit/profile']['file'] = 'example.module';
}
?>
I hope that helps others to save time on this one.
DT