代码点火器帮助用户注册脚本


Codeigniter help with user registration script

:)这个问题适用于任何熟悉 Tankauth 插件的人。

我编辑了 tankauth,以便在没有电子邮件验证的情况下填充用户配置文件。

在注册表中,我添加并验证了另外两个名为"first_name"和"last_name"的字段,我想在提交表单时将其添加到user_profiles表中。

下面是 tankauth 函数,该函数在激活用户时将用户 ID 添加到user_profiles表中。我注释掉了如果($activated)。问题是我不知道如何将我的新字段first_name插入并last_name到数据库中。 我尝试的任何事情都会不断收到错误。

function create_user($data, $activated = TRUE)
    {
        $data['created'] = date('Y-m-d H:i:s');
        $data['activated'] = $activated ? 1 : 0;
        if ($this->db->insert($this->table_name, $data)) {
            $user_id = $this->db->insert_id();
            //if ($activated)
            $this->create_profile($user_id);
            return array(
                         'user_id' => $user_id,
                         'first_name' => $first_name, //added by me
                                                 'first_name' => $first_name, //added by me
                         );
        }
        return NULL;
    } 

以上与

private function create_profile($user_id) 
    {
        $this->db->set('user_id', $user_id);
        $this->db->set('first_name', $first_name); //added by me
        return $this->db->insert($this->profile_table_name);
    } 

有人可以分享一些指导吗?

尝试删除private function create_profile中的private

此外,您可能希望将create_profile函数更改为:

function create_profile( $user_id ) {
    $data = array(
        'user_id' => $user_id,
        'first_name' => $first_name // Hopefully this is being set correctly.
    );
    return $this->db->insert( $this->profile_table_name, $data );
}

如果这些都不起作用。尝试使用echo $this->db->last_query();

希望有帮助。