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) »
  • hook post_edit_individual not called during quick Edit
Pages: [1]

Author Topic: hook post_edit_individual not called during quick Edit  (Read 797 times)

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
hook post_edit_individual not called during quick Edit
July 18, 2013, 07:56:21 am
I've written a callhooks_civicrm_post_edit_Individual($objectId, &$objectRef) to determine CDN provincial and federal electoral districts after a Contact record has been Edited. All works well when I use the main Edit button in the view Contact screen - watchdog (reverse order):

callhooks   07/18/2013 - 07:37   callhooks_civicrm_post_edit_Individual($objectId, ...   karin (we're in)
callhooks   07/18/2013 - 07:37   http://represent.opennorth.ca/postcodes/V3G2Y5/   karin (talking to API opennorth)
callhooks   07/18/2013 - 07:37   Abbotsford       (determined the federal district)
callhooks   07/18/2013 - 07:37   Abbotsford-Mission   (determined the provincial district)

However - when I hover on the Home Address and click the quick Edit button that pops up to quickly update a person's address details - the hook does not fire - and thus no watchdog statements - no districts. I read a post by Erik last fall that suggested that this is supposed to be working as of 4.2.2 (but perhaps I misunderstood). Is there a way to make this work?

-- Karin

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: hook post_edit_individual not called during quick Edit
July 18, 2013, 04:20:37 pm
If you are wanting to capture all address changes you need to watch for changes to the Address object not the contact object
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: hook post_edit_individual not called during quick Edit
July 18, 2013, 04:22:54 pm
Ah - of course... thank you - much!

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: hook post_edit_individual not called during quick Edit
July 18, 2013, 08:57:41 pm
hook_civicrm_post_edit_Address($objectId, &$objectRef)
Is working great - and doesn't just also fire during a quick Edit - it also helps to prevent this hook from being called too often.

It doesn't look like there is a
hook_civicrm_post_edit_Demographics($objectId, &$objectRef)
There are a couple of things we do when people's records are marked is_deceased. Right now - using edit_Individual - but it would be sweet to narrow this down further as well.

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: hook post_edit_individual not called during quick Edit
July 18, 2013, 09:01:31 pm
Hold on looks like there is a hook for Demographics in 4.3.0

http://issues.civicrm.org/jira/browse/CRM-11291

I'll have to double check my attempt to invoke it.

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: hook post_edit_individual not called during quick Edit
July 19, 2013, 07:20:09 am
Looks like

hook_civicrm_post_edit_Demographics($objectId, &$objectRef)

is indeed not working for 4.2.x
[And we can't take this site to 4.3.x just yet]

Where in the codebase do eg hook_civicrm_post_edit_Address($objectId, &$objectRef) live?

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: hook post_edit_individual not called during quick Edit
July 19, 2013, 01:21:40 pm

seems like you are using a wrapper function which is triggered from the generic civicrm post hook to concatenate the operation and the object

note that demographics is part of the contact object and as such does not exist as a table in the db

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

KarinG

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
  • CiviCRM version: 4+
  • CMS version: Drupal 6 / 7
  • MySQL version: MariaDB
  • PHP version: 5.3/5.4/5.5
Re: hook post_edit_individual not called during quick Edit
July 19, 2013, 01:43:31 pm
Quote
seems like you are using a wrapper function which is triggered from the generic civicrm post hook to concatenate the operation and the object

Yes I am. Sorry that would be confusing if new folks would read this post - It's basically:
function callhooks_civicrm_post($op, $objectName, $objectId, &$objectRef)
then checking to see if a specific function_exists("callhooks_civicrm_post_${op}_${objectName}
etc.

Quote
note that demographics is part of the contact object and as such does not exist as a table in the db

So that means I'll need to keep using $op = edit and $objectName = Individual in order to trigger a response to an is_deceased status update - and I'll let staff know that they can not use the Quick Edit for updating the is_deceased status to = 1 but to use the Main Edit one instead.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook post_edit_individual not called during quick Edit

This forum was archived on 2017-11-26.