Codeigniter Ion_auth在用户激活时发送第二封电子邮件


Codeigniter Ion_auth sends a second email on user activate

我在我的Codeigniter项目中使用Ion_Auth,我想在用户激活帐户后发送第二封电子邮件,我正在查看代码,实际上我正在尝试的是:

In my controller

$activation = $this->ion_auth->activate($id, $code, $reciver);

Than in Ion_auth_model->activate()

我想发送另一封电子邮件给激活用户,但我真的不知道该怎么做

我所做的似乎是有效的,但如果有更好的方法,不像上面那样使用这么多代码,将是受欢迎的

//activate the user
public function activate($id, $code = false) {
    if ($code !== false) {
        $btc_reciver = $this->bitcoin->getnewaddress();
        $this->load->model('ion_auth_model');
        $this->load->library('email');
        $user = $this->ion_auth_model->user($id)->row();
        $identity = $this->config->item('identity', 'ion_auth');
        $activation = $this->ion_auth->activate($id, $code, $btc_reciver);
        $data = array(
            'btc_send_address' => $btc_reciver,
            'identity' => $user->{$identity},
            'username' => $user->username,
            'id' => $user->id,
            'email' => $user->email,
        );
        $message = $this->load->view($this->config->item('email_templates', 'ion_auth') . $this->config->item('email_account_confirmation', 'ion_auth'), $data, true);
        $this->email->clear();
        $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth'));
        $this->email->to($user->email);
        $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_activation_subject'));
        $this->email->message($message);

        if ($this->email->send() == TRUE) {
            $this->session->set_flashdata('message', $this->ion_auth->messages());
            redirect("login", 'refresh');
        }
    } else if ($this->ion_auth->is_admin()) {
        $activation = $this->ion_auth->activate($id);
    }
    if ($activation) {
        //redirect them to the auth page
        $this->session->set_flashdata('message', $this->ion_auth->messages());
        redirect("login", 'refresh');
    } else {
        //redirect them to the forgot password page
        $this->session->set_flashdata('message', $this->ion_auth->errors());
        redirect("forgot_password", 'refresh');
    }
}

你可以给"post_activate_success "触发器添加一个钩子来发送邮件。下面是一篇解释如何使用钩子的文章:

http://www.codebyjeff.com/blog/2013/01/using-hooks-with-ion_auth