[development] Custom user data tab not displayed with hook_user

Steve Edwards killshot91 at gmail.com
Tue Mar 2 20:10:55 UTC 2010

I took over a site that has custom user data stored in a separate table, and I would like to display those fields in a separate tab in the user profile.  I figured I could just write a page and form function, but I'd like to integrate it with user data.  I have the following hook_user implementation:

function hsi_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {   
 case 'categories':	
      $data[] = array(
        'name' => 'hsi_demo',
        'title' => 'Demographics',
        'weight' => 3,
        'access callback' => TRUE,
      return $data;
    case 'form':
	$data = db_fetch_object(db_query("SELECT bday, gender, nation, religion, heard FROM hsi_demo WHERE uid = %d", $account->uid));
	$countries = _hsi_countries();
        $fields['hsi_demo']['bday'] = array(
	  '#type' => 'date',
          '#title' => 'Birth Date',
          '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
          '#required' => TRUE,
	$fields['hsi_demo']['gender'] = array(
	  '#type' => 'select',
	  '#title' => 'Gender',
	  '#options' => array('m' => 'Male', 'f' => 'Female'),
	  '#default_value' => $data->gender,
	$fields['hsi_demo']['nation'] = array(
	  '#type' => 'select',
	  '#title' => 'Country',
	  '#options' => $countries,
	  '#default_value' => $data->nation,
	$fields['hsi_demo']['denomination'] = array(
	  '#type' => 'select',
	  '#title' => 'Denomination',
	  '#options' => $countries,
	  '#default_value' => $data->denomination,
          '#options' => $denominations,
	return $fields;

The problem is, I don't get my Demographics tab displayed.  Do I also need a hook_menu entry for this path (i.e. user/%user/edit/hsi_demo)? What else am I missing?



More information about the development mailing list