【问题标题】:Codeigniter Ion_auth sends a second email on user activateCodeigniter Ion_auth 在用户激活时发送第二封电子邮件
【发布时间】: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


    【解决方案1】:

    您可以在“post_activate_successful”触发器中添加一个挂钩来发送电子邮件。这是一篇解释如何使用钩子的文章:

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

    【讨论】:

    • 感谢您的反馈。恭喜这个漂亮的图书馆
    猜你喜欢
    • 2018-08-19
    • 2011-01-02
    • 1970-01-01
    • 2014-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多