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_civicrm_post returns (mostly) empty params for GroupContact
Pages: [1]

Author Topic: hook_civicrm_post returns (mostly) empty params for GroupContact  (Read 850 times)

marc

  • Guest
hook_civicrm_post returns (mostly) empty params for GroupContact
June 16, 2010, 09:30:58 am
Hi,

I am running the following code:

Code: [Select]
function mailman_civicrm_post( $op, $objectName, $objectId, &$objectRef ) {
        if ($objectName == "GroupContact" && ($op == "create" || $op == "edit" || $op == "delete")) {
            print_r("ObjectID \n");
            print_r($objectID);
            print_r("ObjectName \n");
            print_r($objectName);
            print_r("operation \n");
            print_r($op);
            print_r("objectRef \n");
            print_r($objectRef);
            die();
         }
}

and get the following output when changing someone's membership of a group:
Code: [Select]
ObjectID
ObjectName GroupContact
operation edit
objectRef Array ( [0] => 1 )

As you can see, there is hardly any information in objectID or objectRef, and I would like to log - for mailing lists - to which groups there have been changes. Is it normal/intended that I don't get any extra information on person or group that gets edited and if so, what would you suggest I do to log changes to group memberships?

Thanks,

Marc

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_civicrm_post returns (mostly) empty params for GroupContact
June 16, 2010, 10:52:02 am

do a print_r( $objectId ) and u'll get a value :)

$objectId == the group ID

$objectRef == array of contacts ids being added to above group

its basically a simple join table, are you looking for anything more specific

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

marc

  • Guest
Re: hook_civicrm_post returns (mostly) empty params for GroupContact
June 16, 2010, 11:48:59 pm
Oops to the first... embarrassing.

And $objectRef is all I need, just didn't know what it was for.

Thanks Lobo!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook_civicrm_post returns (mostly) empty params for GroupContact

This forum was archived on 2017-11-26.