SugarCRM – Logic Hooks


SugarCRM Logic Hooks allows you to append actions to system events such as when creating, editing, and deleting records. This post gives you fast info how to implement them properly. For detail info read documentation linked at end of the post.


Add php hooks_arrays in: /custom/extensions/modules/{module}/Ext/LogicHooks

$hook_array['before_save'][] = Array(
    //Processing index. For sorting the array.
    //Label. A string value to identify the hook.
    'before_save hook',
    //The PHP file where your class is located.
    //The class the method is in.
    //The method to call.

Add logic to file in: /custom/modules/{module}/hooks/

Basically it needs to match php file location and name like defined above in $hook_array. Also it needs to have class and function same as declared in $hook_array. 
i.e. module hooks can be called on events like: before_safe, after_save, etc.

class OpportunitiesHook {

    public function beforeSave(&$bean, $event, $arguments)
        //$GLOBALS["log"]->fatal("beforeSave called!!");
        if ($event != 'before_save') {


Full documentation about logic hooks you can find here.

Read about SugarCRM logging here.

Marko Vucak Author


Leave a Reply

Your email address will not be published. Required fields are marked *