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) »
  • Post Hook showing edit when create employer via contact edit
Pages: [1]

Author Topic: Post Hook showing edit when create employer via contact edit  (Read 566 times)

Parvez

  • I post occasionally
  • **
  • Posts: 91
  • Karma: 7
Post Hook showing edit when create employer via contact edit
February 21, 2012, 04:14:46 am
Hi

We have some code in the civicrm_post hook which allocates a unique external id on creation of a new contact. When editing a contact and creating a new employer the hook doesn't get fired with 'create' operation for the new employer and therefore we fail to allocate the external id.

Code: [Select]
    if ($op == 'create' && isset($objectRef->contact_type) ) {
      // Code here
    }

I would expect this hook to be fired at the data object level and therefore is should fire twice in this circumstance i.e. once for the edit of the contact and also for the creation of the employer record.

Is this is bug or expected behaviour?

If it is expected then what is the workaround to the problem i.e. how can I ensure external id is always allocated to new records using hooks?


Thanks

Parvez

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Post Hook showing edit when create employer via contact edit
February 21, 2012, 04:20:32 am
IMO a bug
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Post Hook showing edit when create employer via contact edit

This forum was archived on 2017-11-26.