1

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?

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.