I'm using Ion Auth in my project and I want to send Welcome Email to user after user activates his/her email.I know that i can do it using post_activate_successful hook but i need id of user in my hook file so i don't know how to pass that id in hook.
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_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();
}
}
I think you should simply store the user id in a a session variable then after sending the email, you unset the session variable again. Session variables are accessible every where in your application