Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用钩子在codeigniter Ion auth中激活用户后发送电子邮件_Codeigniter_Ion Auth - Fatal编程技术网

使用钩子在codeigniter Ion auth中激活用户后发送电子邮件

使用钩子在codeigniter Ion auth中激活用户后发送电子邮件,codeigniter,ion-auth,Codeigniter,Ion Auth,我在我的项目中使用了Ion Auth,我想在用户激活他/她的电子邮件后向用户发送欢迎电子邮件。我知道我可以使用post\u activate\u successfulhook来完成,但我需要在我的hook文件中输入用户id,所以我不知道如何在hook中传递该id config/hooks.php $hook['post_activate_successful'][] = array( "class" => "Welcom_email",// any name of class

我在我的项目中使用了Ion Auth,我想在用户激活他/她的电子邮件后向用户发送欢迎电子邮件。我知道我可以使用post\u activate\u successfulhook来完成,但我需要在我的hook文件中输入用户id,所以我不知道如何在hook中传递该id

config/hooks.php

$hook['post_activate_successful'][] = array(
    "class"    => "Welcom_email",// any name of class that you want
    "function" => "index",// a method of class
    "filename" => "Welcom_email.php",// where the class declared
    "filepath" => "hooks"// this is location inside application folder
);
hooks/Welcome\u email.php

class Welcom_email
{
    public function index()
    {
        $this->load->library('email');
        //$id variable is not defined here so how can I pass that variable hook
        $user = $this->ion_auth_model->user($id)->row();
        $message = $this->load->view('auth/email/welcome_email',null, 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);
        $this->email->send();
    }

}

我认为您应该简单地将用户id存储在会话变量中,然后在发送电子邮件后,再次取消设置会话变量。会话变量在应用程序中的任何位置都可以访问

是……但不使用会话是否可以执行此操作?帐户将被激活并自动创建会话。我认为您应该调用一个模型,然后查询您的数据库,根据他用于确认的电子邮件地址获取用户ID。