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) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Save custom field when creating new contact
Pages: [1]

Author Topic: Save custom field when creating new contact  (Read 900 times)

muppel

  • I’m new here
  • *
  • Posts: 22
  • Karma: 0
  • CiviCRM version: CiviCRM 3.4.4
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.56
  • PHP version: 5.3.6
Save custom field when creating new contact
March 20, 2011, 01:09:34 pm
Hallo,

I have a custom field, which I display in the "Contact Details" inline tab.
When an existing contact is updated, I use the hook_civicrm_postProcess - which works fine.
When a new contact is created, I want to use the hook_civicrm_post.

My question is, how can I get the value of the custom field to be saved? I've got it in the hook_civicrm_postProcess, but not in the hook_civicrm_post.

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: Save custom field when creating new contact
March 20, 2011, 01:54:35 pm

any reason u dont use the same hook for new contacts?

also can u check and see if hook_civicrm_custom meets your needs

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

muppel

  • I’m new here
  • *
  • Posts: 22
  • Karma: 0
  • CiviCRM version: CiviCRM 3.4.4
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.56
  • PHP version: 5.3.6
Re: Save custom field when creating new contact
March 21, 2011, 12:02:49 am
I need the id of the new contact, which is not available in the hook civicrm_postProcess.

hook_civicrm_postProcess( $formName, &$form ) -  here I've got the form values, but not the ID of the new contact, which I need for the custom_value_table as entity_id.

hook_civicrm_post( $op, $objectName, $objectId, &$objectRef ) - this hook gives me the new ID, but have no access to the form values.

Any idea...?

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Save custom field when creating new contact
March 21, 2011, 01:52:01 am
I use $form->_contactId in the hook civicrm_postProcess, it gives me the contact_id of the newly created contact?
Erik
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Save custom field when creating new contact

This forum was archived on 2017-11-26.