Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter储罐认证添加字段_Php_Codeigniter_Tankauth - Fatal编程技术网

Php Codeigniter储罐认证添加字段

Php Codeigniter储罐认证添加字段,php,codeigniter,tankauth,Php,Codeigniter,Tankauth,我使用CI tank_auth library创建用户注册表单,需要添加tank_auth未附带的新字段 我确实提到了这一点,但它从来没有帮助我解决我的疑问 比如说,我想在注册过程中增加“Name”字段,我在视图和function register()controller中创建了它,这很好用,除了我想把它放在user\u profiles表中,我创建了一个名为Name的列,然后在tank\u auth model的users.php中,我找到以下方法并添加: private function c

我使用CI tank_auth library创建用户注册表单,需要添加tank_auth未附带的新字段

我确实提到了这一点,但它从来没有帮助我解决我的疑问

比如说,我想在注册过程中增加“Name”字段,我在视图和
function register()
controller中创建了它,这很好用,除了我想把它放在
user\u profiles
表中,我创建了一个名为
Name
的列,然后在tank\u auth model的users.php中,我找到以下方法并添加:

private function create_profile($user_id, $name)
{
    $this->db->set('user_id', $user_id);
    $this->db->set('name', $name);
    return $this->db->insert($this->profile_table_name);
}
当我运行注册时,没有发生错误,我检查表,
名称
字段不是insert,因此我猜可能没有参数传递到
$name
,这是我的问题,我在哪里可以将参数传递到此函数

我希望有人与这个图书馆的经验可以消除我的疑虑

谢谢

解决方案:

@Joan Diego Rodriguez在注册过程中如何向tank_auth的user_profiles表中添加额外字段方面有很好的实践


希望这将有助于寻找相同解决方案的人

您好,我已经遇到了这个问题,我的解决方案很简单

创建用户->创建用户配置文件->更新用户配置文件

请转到TA模型“用户”并添加此方法/功能

function update_user_profile($user_id, $data)
{
    $this->db->where('user_id', $user_id);
    $this->db->update($this->profile_table_name, $data);
}
复制auth.php(以防万一)并在register方法中进行一些调整(如下所示)请注意这里还有一些代码将原始代码放在那里(我修改了我的代码)

检索一个用户(刚刚添加where子句)


谢谢也许你知道如何从
user\u profiles
表中检索用户信息吗?
if ($this->form_validation->run()) {
// validation ok

    if (!is_null(<here is some more code>)) {

        $user_data = array(
    'first_name' => $this->form_validation->set_value('first_name'),
    'last_name' => $this->form_validation->set_value('last_name'),
    );

    //$this->load->model('tank_auth/users');
    $this->users->update_user_profile($data['user_id'], $user_data); //update happens

    } else {

        $errors = $this->tank_auth->get_error_message();
        foreach ($errors as $k => $v)   $data['errors'][$k] = $this->lang->line($v);

    }
}
function get_all_users() {
    $this->db->select('users.id, users.username, users.activated, users.banned, users.ban_reason, user_profiles.id as up_id, user_profiles.first_name, user_profiles.last_name');
    $this->db->from('users');
    $this->db->join('user_profiles', 'users.id = user_profiles.user_id');
    return $this->db->get()->result();
}
function get_ser($id){
    $this->db->select('users.id, users.username, users.activated, users.banned, users.ban_reason, user_profiles.id as up_id, user_profiles.first_name, user_profiles.last_name');
    $this->db->from('users');
    $this->db->join('user_profiles', 'users.id = user_profiles.user_id');
    $this->db->where('users.id', $id);
    $q = $this->db->get();
    return ($q->num_rows() > 0) ? $q->result()[0] : FALSE;
}