从Ion Auth中处于条件下的函数获取返回值


Get returned value from function in condition in Ion Auth

在auth/create_user函数中,有以下代码:

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

这是创建新用户的时候。$this->ion_auth->register函数返回新创建的用户id。我的问题是,如何访问该用户id?它没有分配给变量,我不知道如何访问它。

谢谢。

只需将其分配给一个变量:

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

我认为Abra的答案是错误的。。。您不会从register方法获取id,它只会返回True或False。

尝试使用CI的$this->db->insert_id()将最后插入的用户的ID获取到表中