Skip to content

Commit

Permalink
Merge pull request #12309 from jaapjansma/issue_180_deleting_custom_v…
Browse files Browse the repository at this point in the history
…alues

Fix for #180: passing the entity ID to the custom hook when deleting a custom value
  • Loading branch information
colemanw authored Jun 13, 2018
2 parents 8b9d23d + 2c57d73 commit ffa950d
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 ffa950d

Please sign in to comment.