CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • get the contribution ID in the post process hook
Pages: [1]

Author Topic: get the contribution ID in the post process hook  (Read 1119 times)

RachelWright

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 3
  • CiviCRM version: 4.2.7
  • CMS version: Joomla 2.5.17
  • MySQL version: 5.5.37
  • PHP version: 5.4.26
get the contribution ID in the post process hook
May 13, 2013, 07:34:02 am
I am very close to completing my code to send to owner of a PCP an email when they get a donation. I have my code written as a postprocess hook after the CRM_Contribute_Form_Contribution_Confirm form.

 I actually have it working at the moment but am trying to get a fair amount of information in the email.  I've gotten these variables to work for me:
$form->_contactID;
$form->_pcpId;
$form->_amount;

which is great, but I haven't been able to figure out what existing variable would give me the contribution ID, nor been able figure out how to add code to the confirm.php file to pass the contribution id to this hook. Suggestions?


Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: get the contribution ID in the post process hook
May 13, 2013, 09:22:27 am
Have you looked at using hook_civicrm_post() ?
Try asking your question on the new CiviCRM help site.

RachelWright

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 3
  • CiviCRM version: 4.2.7
  • CMS version: Joomla 2.5.17
  • MySQL version: 5.5.37
  • PHP version: 5.4.26
Re: get the contribution ID in the post process hook
May 13, 2013, 11:28:34 am
As opposed to hook_civicrm_postProcess? Would a different set of variables be available to me? Would it still run when someone confirmed their donation?

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: get the contribution ID in the post process hook
May 13, 2013, 11:31:49 am
hook_civicrm_postProcess is for form processing - form variables will be available but not necessarily other things like contribution id.
hook_civicrm_post is fired whenever anything is saved to the database, so it will run anytime a contribution is saved (really it runs anytime anything is saved, so you need to wrap your code in some specific conditionals. It passes the id explicitly.
Try asking your question on the new CiviCRM help site.

RachelWright

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 3
  • CiviCRM version: 4.2.7
  • CMS version: Joomla 2.5.17
  • MySQL version: 5.5.37
  • PHP version: 5.4.26
Re: get the contribution ID in the post process hook
May 13, 2013, 12:45:27 pm
Thank you for explaining that, it makes a bit more sense now (when you might use one over the other and why some information is available and other not.)

I will see what I can rebuild in this hook!! Thanks again!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: get the contribution ID in the post process hook
May 13, 2013, 02:28:21 pm

I also just filed a PR to expose the contribution ID to the form object. In the past (legacy reasons), we've not been very good at exposing such IDs at the form layer

https://github.com/civicrm/civicrm-core/pull/727

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

RachelWright

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 3
  • CiviCRM version: 4.2.7
  • CMS version: Joomla 2.5.17
  • MySQL version: 5.5.37
  • PHP version: 5.4.26
Re: get the contribution ID in the post process hook
May 14, 2013, 12:51:14 pm
Thanks Lobo, I had tried something similar but not correct, this is spot on!!!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • get the contribution ID in the post process hook

This forum was archived on 2017-11-26.