1

所以我正在使用 kohana 用户模块,我想扩展我的注册页面,现在它添加了用户名、电子邮件和密码,但我想添加一些额外的字段,我只是找不到在哪里可以做.

我找到function action_register了导致的,Auth::instance()->register($_POST, true);所以我发现了function register($fields)导致的$user = ORM::factory('user');$user->create_user($fields, array()所以我被困在这里的某个地方,我什至不确定我是否走的是正确的道路......

4

1 回答 1

3

只需在application/classes/model文件夹下创建user.php文件并将其放入:

<?php

defined('SYSPATH') or die('No direct access allowed.');

class Model_User extends Model_Auth_User
{
   public function create_user($values, $expected)
   {
      // Your definition of the function
   }
}

检查注册功能后,这里是其他字段的地方(第22-27行):

$user->create_user($fields, array(
                                'username',
                                'password',
                                'email',
                                'user_type',
                                'other field',
                                'other field2',
                        ));

当然,您需要拥有other_field并存other_field2在于您的表中。

于 2011-12-22T15:29:37.000 回答