Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 1.6
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
I found an odd issue in the civicrm_post hook. My code there looks like:
if ($op == 'edit' || $op == 'create') {
$crm_params = array('contact_id' => $objectId);
$return_properties = array(
'organization_name' => 1, 'home_URL' => 1, 'street_address' => 1,
'supplemental_address_1' => 1, 'supplemental_address_2' => 1, 'city' => 1, 'state_province' => 1, 'postal_code' => 1,
'country' => 1, 'phone' => 1, 'email' => 1,
'custom_12' => 1, 'custom_13' => 1,
'custom_15' => 1, 'custom_16' => 1,
'custom_17' => 1, 'custom_18' => 1,
'custom_19' => 1, 'custom_20' => 1,
'custom_21' => 1,
'location' => array('Main' => array('phone-Fax' => 1)),
);
$contact = crm_contact_search($crm_params, $return_properties);
When $op == edit, the $contact object is returned, including all the custom fields.
When $op == create, however, the $contact object is returned with only the default fields, missing all custom fields:
Array
(
[0] => Array
(
[174] => Array
(
[contact_id] => 174
[organization_id] => 70
[organization_name] => test organization
[location_id] => 159
[address_id] => 146
[street_address] => asdfj askdj
[city] => ljnsad
[postal_code] => 323
[state_province_id] => 5136
[state_province] => GT
[country_id] => 1196
[country] => South Africa
[phone_id] => 170
[phone] => 0459834
[email_id] => 214
[email] => mark@localhost
)
)
[1] => Array
...This second array does include all the metadata about the custom fields, but not the custom field data itself...
The result is that I have to create an org, then edit and save it again (without any changes) in order to have access to the custom fields in the civicrm_post hook.