Skip to content

Commit

Permalink
Fix for civicrm#180: passing the entity ID to the custom hook when de…
Browse files Browse the repository at this point in the history
…leting a custom value record.
  • Loading branch information
jaapjansma committed Jun 13, 2018
1 parent a42a500 commit 2c57d73
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CRM/Core/BAO/CustomValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,18 @@ public static function deleteCustomValue($customValueID, $customGroupID) {
// first we need to find custom value table, from custom group ID
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupID, 'table_name');

// Retrieve the $entityId so we can pass that to the hook.
$entityID = CRM_Core_DAO::singleValueQuery("SELECT entity_id FROM {$tableName} WHERE id = %1", array(
1 => array($customValueID, 'Integer'),
));

// delete custom value from corresponding custom value table
$sql = "DELETE FROM {$tableName} WHERE id = {$customValueID}";
CRM_Core_DAO::executeQuery($sql);

CRM_Utils_Hook::custom('delete',
$customGroupID,
NULL,
$entityID,
$customValueID
);
}
Expand Down

0 comments on commit 2c57d73

Please sign in to comment.