Couple questions about extending functionality…
1- Is there a way to automatically log a user in after they register (assuming everything passes and email validation is not required)?
2 - Has anyone modified the library to redirect to the page the user came from rather than back to the homepage after login?
Thanks!
Yes. This is for Tank Auth 1.0.9
In libraries/Tank_auth, change
private function create_autologin($user_id)
to
function create_autologin($user_id)
DONT copy paste the whole block BELOW, mine is slightly customised.
In controllers/auth, comment out $this->_show_message and check out the last 2 lines I added.
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'),
$email_activation,
$profile_array))) { // success
$data['site_name'] = $this->config->item('website_name', 'tank_auth');
if ($email_activation) { // send "activate" email
$data['activation_period'] = $this->config->item('email_activation_expire', 'tank_auth') / 3600;
$this->_send_email('activate', $data['email'], $data);
unset($data['password']); // Clear password (just for any case)
//$this->_show_message('<h1>Registration</h1>' . $this->lang->line('auth_message_registration_completed_1'));
} else {
if ($this->config->item('email_account_details', 'tank_auth')) { // send "welcome" email
$this->_send_email('welcome', $data['email'], $data);
}
unset($data['password']); // Clear password (just for any case)
//$this->_show_message('<h1>Registration</h1>' . $this->lang->line('auth_message_registration_completed_2').' '.anchor('/auth/login/', 'Login'));
}
/*
* Set autologin here
*
*/
$this->tank_auth->create_autologin($data['user_id']);
redirect('/profile/#ui-tabs-1');