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 (Moderator: Donald Lobo) »
  • Strange behavior in hook post after aplying for a membership
Pages: [1]

Author Topic: Strange behavior in hook post after aplying for a membership  (Read 1396 times)

j.benit

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 3.4.7
  • CMS version: Drupal 6
  • MySQL version: 5
  • PHP version: 5
Strange behavior in hook post after aplying for a membership
December 13, 2011, 09:59:57 am
Hi All, i'm having a strange problem, the scenario is the following:
- I have a membership type and a contribution page for that membership.
- I have a custom module with a hook_post to retrieve the contribution id after aplying for the membership using the contribution page.
- I have created a custom set of fields for the contributions, and a profile which uses those fields.
- The contribution page use the profile mentioned above.

At the beginning it was working ok, and a debug on the hook parameters: $objectName, $objectId, after aplying for a membership using the contribution page returned the expected values: "Contribution" and the contribution id, but after a time it started to fail and now every time i apply for the membership using the contribution page i obtain "Individual" as $objectName, and the contact id as $objectId

I guess what could have i changed to make this strange behavior happens?

Thanks a lot for your time.


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: Strange behavior in hook post after aplying for a membership
December 13, 2011, 11:46:31 am

note that multiple hooks can be called during script execution

Individual is probably the first one. Are u exiting on trapping the hook?

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

j.benit

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 3.4.7
  • CMS version: Drupal 6
  • MySQL version: 5
  • PHP version: 5
Re: Strange behavior in hook post after aplying for a membership
December 14, 2011, 04:39:34 am
Thanks Lobo, your reply made me think about the hooks are called not only one time, they are called several times during a script execution.

I was going paranoic because i was only detecting the initial content of the hook parameters, and in the first call, for some reason, the object name was "Individual", but in one of the next calls the object was the contribution. Finally the problem was a fail in a query inside that hook. But the original confusion about the object name in the hook made me think in the wrong direction.

Thanks a lot for your time.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Strange behavior in hook post after aplying for a membership

This forum was archived on 2017-11-26.