Logic hook not work together

Hi guys, I need to have two “after_relationship_add” logic hooks for my “Cs_Cliente” module, hooks only work when commenting on one of them, I can’t get them to work together
this is my logichook.php file :

 <?php

$hook_version = 1; 

$hook_array = Array(); 
$hook_array['after_relationship_add'] = Array();
$hook_array['after_relationship_add'][] = Array(
78,
'custom/modules/Cs_Cliente/assigned_products.php',
'assigned_products_c',
'after_add'
);

$hook_array = Array(); 
$hook_array['after_relationship_add'] = Array();
$hook_array['after_relationship_add'][] = Array(
78,
'custom/modules/Cs_Cliente/assigned_pop_material.php',
'assigned_pop_material_c',
'after_add');

Preformatted text

Don’t repeat the steps setting up the array, otherwise you’re clearing what you previously did. This should do it:


 <?php

$hook_version = 1; 

$hook_array = Array(); 
$hook_array['after_relationship_add'] = Array();
$hook_array['after_relationship_add'][] = Array(
78,
'custom/modules/Cs_Cliente/assigned_products.php',
'assigned_products_c',
'after_add'
);

$hook_array['after_relationship_add'][] = Array(
85,
'custom/modules/Cs_Cliente/assigned_pop_material.php',
'assigned_pop_material_c',
'after_add');

Also, don’t repeat the order number as it is used to specify the sequence of hooks to execute.

But if I were you I’d consider just moving all your code into a single logic hook, why use two?

1 Like

Hi pgr thank you, I try with your code but i have still an error


It seems that the functions inside these file are not loaded…

@Lawliet

Look at documentation: https://docs.suitecrm.com/developer/logic-hooks/
You skip the second parameter in array.