簡體   English   中英

Codeigniter Ion_auth在用戶激活時發送第二封電子郵件

[英]Codeigniter Ion_auth sends a second email on user activate

我在我的Ion_Auth項目中使用了Ion_Auth ,並且在用戶激活帳戶並且查看代碼之后,我想發送第二Ion_Auth電子郵件,實際上我正在嘗試的是:

在我的控制器中

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

比在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_successful”觸發器即可發送電子郵件。 這是一篇介紹如何使用掛鈎的文章:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM