function hook_user_categories

hook_user_categories()

Define a list of user settings or profile information categories.

There are two steps to using hook_user_categories():

Step one builds out the category but it won't be visible on your form until you explicitly tell it to do so.

The function in step two should contain the following code in order to display your new category:

if ($form['#user_category'] == 'mycategory') {
  // Return your form here.
}

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

File

modules/user/user.api.php, line 216
Hooks provided by the User module.

Code

function hook_user_categories() {
  return array(array(
    'name' => 'account',
    'title' => t('Account settings'),
    'weight' => 1,
  ));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_categories/7.x