Your error is most probably at this line -
$ion_user_id = $this->db->get_where('users', array('email' => $email))->row()['id'];
It refers to the name you are using 'id', which is undefined, meaning that the name does not exist in your array.
In order for us to give you a better answer, show us the correct naming of 'id', is it maybe 'Id' or 'ID' etc. Also show us what your array names are, but the above should suffice to fix your problem.
You can read more on arrays and it's usage at -
PHP array_keys | Tutorial[
^]