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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Finding the sourse of contribution in hook_civicrm_post
Pages: [1]

Author Topic: Finding the sourse of contribution in hook_civicrm_post  (Read 841 times)

Rajesh

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 10
  • CiviCRM version: 4.2.x, 4.3.x, 4.4.x
  • CMS version: Drupal 7.xx, Wordpress 3.5.x - 3.6.x, Joomla 3.1
  • MySQL version: 5.5.20
  • PHP version: 5.3.10
Finding the sourse of contribution in hook_civicrm_post
March 03, 2011, 08:54:25 am
Hi

In hook_civicrm_post, im trying to find the source of the contribution (whether it is from event registration or contribution page), when a new contribution is created.

For the contributions created through contribution pages, i am getting the contribution_page_id. So i can find the source contribution page for that contribution.

But how do i find, if the contribution is created from event registration page? I just need to find the Event id from which the contribution is created.

Thanks

- Rajesh

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: Finding the sourse of contribution in hook_civicrm_post
March 03, 2011, 09:48:35 am

I would use $_GET['q'] and use that to see where the contribution is coming from. Note that you'll need to account for offline contributions also (and probably ignore them based on your use case)

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

Rajesh

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 10
  • CiviCRM version: 4.2.x, 4.3.x, 4.4.x
  • CMS version: Drupal 7.xx, Wordpress 3.5.x - 3.6.x, Joomla 3.1
  • MySQL version: 5.5.20
  • PHP version: 5.3.10
Re: Finding the sourse of contribution in hook_civicrm_post
March 04, 2011, 02:01:46 am
Thanks lobo.

It worked great!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Finding the sourse of contribution in hook_civicrm_post

This forum was archived on 2017-11-26.