【发布时间】:2014-04-21 14:26:19
【问题描述】:
我在我的 Codeigniter 项目中使用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');
}
}
【问题讨论】:
标签: php codeigniter email ion-auth