hooks not working please check

edited July 2017 in Modules
I want to check dependency from other table entry of an module before deleting its entry ..
so if their is no entry for this module exists it allow it to delete else cant be deleted

i have done following things :
model name : Jobs_model


$hook['before_delete_jobs'] = array(
'class' => 'job_hooks',
'function' => 'before_delete_jobs',
'filename' => 'Job_hooks.php',
'filepath' => 'hooks',
'params' => array(),
'module' => 'job');
hooks -> Job_hooks.php

class Job_hooks extends CI_Controller {
public function __construct()
parent::__construct(); // table name
function before_delete_jobs($where)
print_r($where); return FALSE;die(); //just to prevent from getting deleted implement the thing later

but the function did not executing or if executed have no effect
is their any mistake ??? or have other simple way please check


  • edited 1:39AM
    The "module" parameter in the hook is actually referencing an advanced module folder name (which is a little confusing). Do you have an advanced module in the "fuel/modules/job" folder? If not and it's in your fuel/application folder, remove the "module" parameter on the hook or change it to "app" and see if that fixes your issue.
  • edited 1:39AM
    i have removed the module parameter those it is still not working ...
    instead on my Jobs_model
    "on_before_delete" function is working
    public function on_before_delete($values)
    return FALSE;
    but if i remove the die statement it is still removing the entry .. is their a way to stop it
    instead of redirecting it .
  • edited 1:39AM
    What is the path to the Job_hooks.php file? Also, the Job_hooks.php file shouldn't be on a controller but exist in it's own class file similar to the fuel/modules/fuel/hooks/Fuel_hooks.php file which is based on the native CI hooks:
  • edited 1:39AM
    that is in application->hooks folder
  • edited 1:39AM
    What does your class look like now to execute the fuel/application/hooks/Jobs_hooks::before_delete_jobs method? Also, is your fuel/application/config/hooks.php configuration set to the following and you have a module of "jobs" set in your fuel/application/config/MY_fuel_modules.php:
    $hook['before_delete_jobs'] = array( 'class' => 'Job_hooks', 'function' => 'before_delete_jobs', 'filename' => 'Job_hooks.php', 'filepath' => 'hooks', 'params' => array() );
Sign In or Register to comment.