I m answering this for any new member having the same question.So :
in case you have the desired callback function inside your controller you do this :
// Somewhere inside you controllers' method you have
$crud->callback_before_update( array ($this, '_prepare_post_array_for_insert') );
// and in the same controllers' file later :
function _prepare_post_array_for_insert($post_array)
{
$CI->db->select('first_name, last_name, fathers_name, mothers_name, birthday' );
$CI->db->where('last_name', $post_array['last_name'] )
->where('first_name', $post_array['first_name'] )
->where('fathers_name', $post_array['fathers_name'] )
->where('mothers_name', $post_array['mothers_name'] )
->where('birthday', $post_array['birthday'] );
$query = $this->db->get('member');
if ( $query->num_rows() > 0 )
{
return FALSE;
}
else
{
$post_array['member_id'] = $this->member_model->get_unused_id();
$post_array['created_at'] = date('Y-m-d H:i:s');
return $post_array;
}
return $post_array;
}
Notice that in this case you use $this inside the callback_before_update() function call
To use it the way you want having all the callbacks inside a helper file do it like this :
controller file :
class Member extends CI_Controller
{
public function __construct()
{
parent::__construct();
// Load the helper file which will have your callback functions gathered inside
$this->load->helper('member_registration'); //file here is member_registration.php
}
public function insert_member()
{
// some of your code here ...etc etc
// note $this is missing
$crud->callback_before_insert('_prepare_post_array_for_insert' );
// rest of your code goes on
}
}
and inside application/helpers you have a helper file named "member_registration.php" including something like this :
<?php if( ! defined('BASEPATH') ) exit('No direct script access allowed');
if ( ! function_exists('_prepare_post_array_for_insert'))
{
function _prepare_post_array_for_insert($post_array)
{
$CI =& get_instance();
$CI->db->select('first_name, last_name, fathers_name, mothers_name, birthday' );
$CI->db->where('last_name', $post_array['last_name'] )
->where('first_name', $post_array['first_name'] )
->where('fathers_name', $post_array['fathers_name'] )
->where('mothers_name', $post_array['mothers_name'] )
->where('birthday', $post_array['birthday'] );
$query = $CI->db->get( 'member' );
if ( $query->num_rows() > 0 )
{
return FALSE;
}
else
{
$post_array['member_id'] = $CI->member_model->get_unused_id();
$post_array['created_at'] = date('Y-m-d H:i:s');
return $post_array;
}
}
}
Notice that inside the helper you are using $CI =& get_instance(); to get CIs intance and then you are using the var $CI instead of $this
Hope this helps someone