Example Call Function After Insert Grocery Crud Codeigniter
public function users() {
$crud = new grocery_CRUD();
$crud->set_table('users');
$crud->set_subject('User');
$crud->required_fields('username');
$crud->columns('username', 'email', 'real_name', 'active');
$crud->fields('username', 'email', 'password', 'real_name', 'active');
$crud->callback_after_insert(array($this, 'log_user_after_insert'));
$crud->callback_after_update(array($this, 'log_user_after_update'));
$output = $crud->render();
$this->_example_output($output);
}
function log_user_after_insert($post_array,$primary_key)
{
$user_logs_insert = array(
"user_id" => $primary_key,
"created" => date('Y-m-d H:i:s'),
"last_update" => date('Y-m-d H:i:s')
);
$this->db->insert('user_logs',$user_logs_insert);
return true;
}