Logic hooks from custom module are not firing

Hello,

I have a problem with logic hooks in a custom module. They’re not firing if I use the extension framework, but they
work if I put them in ‘custom/modules/logic_hooks.php’. I did run ‘Quick Repair and Rebuild’.

Help would be greatly appreciated.

I am using SuiteCRM 7.9.1.

I have put this code in custom/Extension/modules/SHACC_SH_Accounts/Ext/LogicHooks/init_hooks.php


<?php
if(empty($hook_array)){
    $hook_array = Array();
}
if(empty($hook_array['after_save'])) {
    $hook_array['after_save'] = Array();
}

$hook_array['after_save'][] = Array(1, 'Test', 'custom/modules/SHACC_SH_Accounts/SH_Accounts_Hooks.php','SH_Accounts_Hooks', 'hook_method');

And I have this code in custom/modules/SHACC_SH_Accounts/SH_Accounts_Hooks.php, but it doesnt get executed.


<?php

if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class SH_Accounts_Hooks
{
    function hook_method($bean, $event, $arguments)
    {
        // logic
    }
}

You should put a file for your custom module as
custom/modules/SHACC_SH_Accounts/logic_hooks.php

This will be your logic hooks file containing details of the hooks to fire. do not change name of the file.

Inside this file add the contents as

if(empty($hook_array)){
    $hook_array = Array();
}
if(empty($hook_array['after_save'])) {
    $hook_array['after_save'] = Array();
}

$hook_array['after_save'][] = Array(1, 'Test', 'custom/modules/SHACC_SH_Accounts/SH_Accounts_Hooks.php','SH_Accounts_Hooks', 'hook_method');

Try to do Quick R/R and then test it.

2 Likes

This solution works fine for me. thanks @cherub-chum