I created a Crud in which i have to send an Email to a group but before sending the email i have to check if the sender has reached the limit number of emails. If the user reached the max number he will be redirected to an information page and if it s not the case the mail will be sent and the user will be redirected to a second page.
Thus as figured below in the code i 'm using the 'callback_before_insert' in which i will try to make my tests and based on the results i will redirect the user to a specific page. Unfortunately the redirect function is dysfunctional.
public function email() { $this->grocery_crud->set_table('email'); $this->grocery_crud->columns('source','sujet','contenu','groupe'); $this->grocery_crud->fields('source','sujet','contenu' ,'groupe'); $this->grocery_crud->callback_before_insert(array($this,'checking_and_sending')); $output = $this->grocery_crud->render(); $this->_example_output($output); } function checking_and_sending($post_array) { . . . if ($h==0) { redirect('/Bilelou/index.php/communication/func','location'); } else { redirect('/Bilelou/index.php/communication/fun','location'); } }
After verification I noted that the 'grocery_crud->render()' function overwrite the redirect function and force it to still in the main page.
Is there any solution that could overpass this problem.
Thank you for your help in advance.