[eluser]InsiteFX[/eluser]
Try this
Code:
public function login()
{
// Validation rules
$this->validation_rules = array(
array(
'field' => 'email',
'label' => lang('user_email_label'),
'rules' => 'required|trim|callback__check_login'
),
array(
'field' => 'password',
'label' => lang('user_password_label'),
'rules' => 'required|min_length[6]|max_length[20]'
),
);
// Set the validation rules
$this->form_validation->set_rules($this->validation_rules);
// Set the redirect page as soon as they get to login
if(!$this->session->userdata('redirect_to'))
{
$uri = parse_url($this->input->server('HTTP_REFERER'), PHP_URL_PATH);
// If iwe aren't being redirected from the userl ogin page
$root_uri = BASE_URI == '/' ? '' : BASE_URI;
strpos($uri, '/users/login') !== FALSE || $this->session->set_userdata('redirect_to', str_replace($root_uri, '', $uri));
}
// If the validation worked, or the user is already logged in
if ($this->form_validation->run() or $this->ion_auth->logged_in())
{
// Get the user data
$user_data = (object) array(
'email' => $this->input->post('email'),
'password' => $this->input->post('password')
);
$redirect_to = $this->session->userdata('redirect_to')
? $this->session->userdata('redirect_to')
: ''; // Home
$this->session->unset_userdata('redirect_to');
// Call post login hook
$this->hooks->_call_hook('post_user_login');
// Redirect the user
redirect($redirect_to);
}
// Render the view
$this->data->sBodyClass = 'one-col';
$this->data->user_data =& $user_data;
$this->template->build('login', $this->data);
}
InsiteFX