Search code examples
phpion-auth

Get returned value from function in condition in Ion Auth


In the auth/create_user function, there is the following code:

if ($this->form_validation->run() == true && $this->ion_auth->register($username, $password, $email, $additional_data)) {

This is when the new user is being created. the $this->ion_auth->register function returns the newly created user's id. My question is, how do I access that user id? It's not assigned to a variable, and I'm not sure how to access it.

Thanks.


Solution

  • Just assign it to a variable:

    if ($this->form_validation->run() == true &&
       ($id = $this->ion_auth->register($username, $password, $email, $additional_data)))
    {
        echo $id;
    }