drupal自定义用户注册参数

drupal用户注册时,默认只需要提供用户名和密码即可。很多时候这个是完全不够用的,我们还希望在用户注册时记录更多的信息,比如生日,性别和自我介绍等等。这个时候就需要hook_user了:

function yourmodulename_user($op, &$edit, &$user, $category = NULL) {
  switch ($op) {
  //注册时扩展的字段
  case ‘register’:
  $fields[‘personal_profile’][‘custom1’] = array(
    ‘#title’ => t(‘自定义字段1’),
    ‘#type’ => ‘textfield’,
  );
  $fields[‘personal_profile’][‘custom2’] = array(
    ‘#title’ => t(‘自定义字段2’),
    ‘#type’ => ‘textfield’,
  );
  return $fields;

  [……]

阅读全文