I'm fairly new to CI and GC, so my problem might just be syntax issues. I'm trying to send an email to the owner of the record after update of a record by an administrator. The email to administrator on insert works, but the email to the user on update does nothing.
Email functions in controller:
public function email_admin_vehicle() { $this->load->library('email'); $this->email->from('myemail@gmail.com', 'Admin'); $this->email->to('myemail@gmail.com'); $this->email->subject('New Vehicle Added'); $this->email->message('A new vehicle has been registered. Please log in to your admin panel to approve the vehicle.'); $this->email->send(); echo $this->email->print_debugger(); } public function email_user_vehicle($post_array) { $this->load->library('email'); $this->email->from('myemail@gmail.com', 'Cars in the Park'); $this->email->to($post_array['email']); $this->email->subject('Vehicle Updated'); $this->email->message('An administrator has updated your vehicle details. Please log on to your account to view the changes.'); $this->email->send(); echo $this->email->print_debugger(); }
Callbacks and CG functions:
//==================\\ //START: Vehicle Crud //==================\\ public function vehicle() { if (!$this->ion_auth->logged_in()) { redirect('auth/login'); } else { if (!$this->ion_auth->is_admin()) { // Get User_id if standard user $user = $this->ion_auth->user()->row(); // Build Crud $crud = new grocery_CRUD(); $crud->unset_jquery(); // Timestamps $crud->set_model('MY_grocery_Model'); // Table $crud->set_table('vehicle'); // Special Queries $crud->where('vehicle.user_id', $user->id ); // Display Rules $crud->display_as('registration','Licence Plate'); $crud->display_as('user_id','Name'); $crud->display_as('event_id','Event'); $crud->display_as('stand_id','Stand'); $crud->display_as('club_id','Club'); // Relations $crud->set_relation('event_id','event','event_name'); $crud->set_relation('user_id','users','username'); $crud->set_relation('club_id','club','club_name'); $crud->set_relation('stand_id','stand','code'); // Validation $crud->set_rules('year','Year','integer'); $crud->required_fields('make','model','year','country','registration','event','club'); // Fields Rules $crud->unset_add_fields('created','updated','stand_id','verified','paid','user_id','ref_number'); $crud->unset_edit_fields('created','updated','stand_id','verified','paid','user_id','ref_number'); $crud->unset_columns('user_id','created','updated','verified','paid'); $crud->unset_export(); $crud->unset_print(); // Adding Buttons $crud->add_action('Print', '', 'print/single','ui-icon-print'); // Callbacks $crud->callback_after_update(array($this, 'email_user_vehicle')); // Render $output = $crud->render(); $this->_cruds_output($output); } else { $crud = new grocery_CRUD(); $crud->unset_jquery(); // Timestamps $crud->set_model('MY_grocery_Model'); // Table $crud->set_table('vehicle'); // Special Queries // Display Rules $crud->display_as('registration','Licence Plate'); $crud->display_as('user_id','Name'); $crud->display_as('event_id','Event'); $crud->display_as('stand_id','Stand'); $crud->display_as('club_id','Club'); // Relations $crud->set_relation('event_id','event','event_name'); $crud->set_relation('user_id','users','username'); $crud->set_relation('club_id','club','club_name'); $crud->set_relation('stand_id','stand','code'); // Adding Buttons $crud->add_action('Print', base_url().'/assets/img/print.png', 'printforms/single',''); // Unset Fields $crud->unset_add_fields('created','updated','user_id','ref_number'); $crud->unset_edit_fields('created','updated','user_id','ref_number'); // Callbacks //$crud->callback_after_insert(array($this, 'add_new_club_user')); $crud->callback_after_insert(array($this, 'email_admin_vehicle')); //$crud->callback_after_update(array($this, 'email_user_vehicle')); // Render $output = $crud->render(); $this->_cruds_output($output); } } }
As I said it might just be that I don't know what I'm doing at all, but any help would be appreciated.