[eluser]zgames[/eluser]
right now i created two fields into user_profile - first_name, last_name, however i can't insert information into them nor into $user_id anymore heh...
this is probably were my mistake is made or maybe not
libraries/tank_auth:
Code:
function create_user($username, $email, $password, $email_activation)
{
if ((strlen($username) > 0) AND !$this->ci->users->is_username_available($username)) {
$this->error = array('username' => 'auth_username_in_use');
} elseif (!$this->ci->users->is_email_available($email)) {
$this->error = array('email' => 'auth_email_in_use');
} else {
// Hash password using phpass
$hasher = new PasswordHash(
$this->ci->config->item('phpass_hash_strength', 'tank_auth'),
$this->ci->config->item('phpass_hash_portable', 'tank_auth'));
$hashed_password = $hasher->HashPassword($password);
$data = array(
'username' => $username,
'password' => $hashed_password,
'email' => $email,
'last_ip' => $this->ci->input->ip_address(),
);
if ($email_activation) {
$data['new_email_key'] = md5(rand().microtime());
}
if (!is_null($res = $this->ci->users->create_user($data, !$email_activation))) {
$data['user_id'] = $res['user_id'];
$data['password'] = $password;
unset($data['last_ip']);
return $data;
}
}
return NULL;
}
here is the rest part of the code
controllers/auth
Code:
if ($this->form_validation->run()) { // validation ok
if (!is_null($data = $this->tank_auth->create_user(
$use_username ? $this->form_validation->set_value('username') : '',
$this->form_validation->set_value('email'),
$this->form_validation->set_value('password'),
$this->form_validation->set_value('first_name'),
$this->form_validation->set_value('last_name'),
$email_activation))) {
models/tank_auth/users
Code:
function create_user($data, $activated = TRUE)
{
$data['created'] = date('Y-m-d H:i:s');
$data['activated'] = $activated ? 1 : 0;
if (! array_key_exists('role_id', $data))
{
if($this->admin_not_present())
{
$data['role_id'] = 1;
}
else
{
$data['role_id'] = $this->default_role();
}
}
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);
}
return NULL;
}
function create_profile($user_id)
{
$this->db->set('user_id', $user_id);
$this->db->set('first_name', $data['first_name']);
$this->db->set('last_name', $data['last_name']);
return $this->db->insert($this->profile_table_name);
}
can someone show me an example how to extend those damn profiles