正确的答案需要更多的细节。我只能假设你做了什么。
-
您向{users}表中添加了字段。您没有更新数据库模式,这使得drupal_write_record不知道新字段,这就是它们未填充的原因。
-
您使用字段创建了一个新表{my_table}。
在这两种情况下,您都需要
hook_user_insert()
/**
* Implements hook_user_insert().
*/
function mymodule_user_insert(&$edit, $account, $category) {
// Here you add the code to update the entry in {users} table,
// or int your custom table.
// $edit has the values from the form, $account->uid has the
// uid of the newly created user.
}
注意:如果我的第一个假设是正确的,那不是drupal的方法。你应该用第二种方法。即使在这种情况下,也可以使用hook_schema在mymodule.install中创建表,而不是使用db_add_field()。
对于drupal 7,您可以使用配置文件模块(核心)或
profile2
为了实现这一点。
基于该代码
尝试在表单alter中更改为此。
$account = $form['#user'];
$form['account']['detail'] = array(
'#type' => 'textfield',
'#title' => t('Additional Detail'),
'#default_value' => $account->detail,
);