title: Registration with CodeIgniter Ion Auth
body: <p>I am trying to register a user with Ion Auth, but the register() function does not seem to report any error messages. How does one register with Ion Auth? I've already read various tutorials like <a href="http://www.kylenoland.com/a-comprehensive-guide-to-securing-codeigniter-2-x-with-ben-edmunds-ion-auth/" rel="nofollow">this one</a> and <a href="http://www.rappasoft.com/tutorials/5-building-a-simple-codeigniter-application-using-ion-auth.html#.Usm0aPS1ySo" rel="nofollow">this one</a> (and the <a href="http://benedmunds.com/ion_auth/" rel="nofollow">documentation</a>), but they do not seem to be working.</p>
  
  <pre><code>function register()
  {
      // do not allow registration if logged in
      if ($this-&gt;ion_auth-&gt;logged_in())
      {
          redirect('/');
      }
  
      $this-&gt;load-&gt;helper(array('form', 'url'));
      $this-&gt;load-&gt;library('form_validation');
  
      $this-&gt;form_validation-&gt;set_rules('name', 'Name', 'trim|required|xss_clean');
      $this-&gt;form_validation-&gt;set_rules('email', 'Email', 'trim|required|valid_email|callback_email_check');
      $this-&gt;form_validation-&gt;set_rules('email2', 'Email Confirmation', 'trim|required|valid_email|matches[email]');
      $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'trim|required|md5');
  
      if ($this-&gt;form_validation-&gt;run() == FALSE)
      {
          $this-&gt;data['message'] = (validation_errors()) ? validation_errors() : $this-&gt;session-&gt;flashdata('message');
  
          $this-&gt;load-&gt;view('header');
          $this-&gt;load-&gt;view('register', $this-&gt;data);
          $this-&gt;load-&gt;view('footer');
      }
      else
      {
          $username = $this-&gt;input-&gt;post('email');
          $password = $this-&gt;input-&gt;post('password');
          $email = $username;
  
          $additional_data = array(
              'first_name' =&gt; $this-&gt;input-&gt;post('name'),
              'last_name' =&gt; '',
          );
  
          if (!$this-&gt;ion_auth-&gt;email_check($email))
          {
              $group_name = 'users';
              $uId = $this-&gt;ion_auth-&gt;register($username, $password, $email, $additional_data, $group_name);
  
              if ($uId == FALSE)
              {
                  $this-&gt;session-&gt;set_flashdata('message', $this-&gt;ion_auth-&gt;errors());
                  redirect("home/register", 'refresh');
              }
              else
              {
                  redirect('/'); // registration success
              }
          }
      }
  }
  
  function email_check($str)
  {
      if ($this-&gt;ion_auth-&gt;email_check($str))
      {
          $this-&gt;form_validation-&gt;set_message('email_check', 'This email is already registered.');
          return FALSE;
      }
  
      return TRUE;
  }
  </code></pre>