Answers.Body: <p>I see this line in <code>CRM_Contribute_BAO_Contribution</code>:</p>
  
  <pre><code>//update pledge and pledge payment, CRM-3961
  CRM_Pledge_BAO_PledgePayment::resetPledgePayment($id);
  </code></pre>
  
  <p>Looking at <code>CRM_Pledge_BAO_PledgePayment::resetPledgePayment()</code>, I see it calls the DAO method, not the BAO - which is why the hooks (which ARE present) are bypassed.  </p>
  
  <p>I think this would be a good enhancement for core CiviCRM.  <code>CRM_Pledge_BAO_PledgePayment::resetPledgePayment()</code> is a very short function, which could be easily refactored to instantiate the PledgePayment BAO instead of DAO, and call the <code>add()</code> or <code>create()</code> method instead of <code>commit()</code>.  This would cause your hooks to fire.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-20T18:40:16.350Z
Answers.LastActivityDate: 2018-11-20T18:40:16.350Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>On 5.6.0</p>
  
  <ul>
  <li>After create a pledge. </li>
  <li>If is created a new contribution that change the status of the pledge from "Pending" to "Completed" is not incoming in any hook_civicrm_post or hook_civicrm_pre with objectName equal to "Pledge" or "PledgePayment"</li>
  </ul>
  
  <p>Which is the correct way to update the pledge programmatically?</p>
  
Tags: <hooks><pledges><civipledge><status>
Title: Hook pre/post in pledge changed status
ThreadText: # Hook pre/post in pledge changed status
  
  (Asked by: username_0 on 2018-11-20)
  
  On 5.6.0
  
  * After create a pledge.
  * If is created a new contribution that change the status of the pledge from "Pending" to "Completed" is not incoming in any hook\_civicrm\_post or hook\_civicrm\_pre with objectName equal to "Pledge" or "PledgePayment"
  
  Which is the correct way to update the pledge programmatically?
  
  **Tags:** hooks, pledges, civipledge, status
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-20. Score: 2
  
  I see this line in `CRM_Contribute_BAO_Contribution`:
  
  ```
  //update pledge and pledge payment, CRM-3961
  CRM_Pledge_BAO_PledgePayment::resetPledgePayment($id);
  
  ```
  
  Looking at `CRM_Pledge_BAO_PledgePayment::resetPledgePayment()`, I see it calls the DAO method, not the BAO - which is why the hooks (which ARE present) are bypassed.
  
  I think this would be a good enhancement for core CiviCRM. `CRM_Pledge_BAO_PledgePayment::resetPledgePayment()` is a very short function, which could be easily refactored to instantiate the PledgePayment BAO instead of DAO, and call the `add()` or `create()` method instead of `commit()`. This would cause your hooks to fire.
  
  
  ---
  
  