Skip to content

Commit

Permalink
fix get_civi_contact() method #54
Browse files Browse the repository at this point in the history
Contact API seems to fail when passing ‘return’ with an empty value.
Seems to affect CiviCRM 4.7.24
  • Loading branch information
mecachisenros committed Sep 16, 2017
1 parent 44b40cb commit d575c17
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions includes/class-civicrm-caldera-forms-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,20 @@ public static function get_civi_contact( $cid ) {

if ( $cid != 0 ) {

$fields = civicrm_api3( 'Contact', 'getsingle', array(
$params = array(
'sequential' => 1,
'id' => $cid,
));
);

$fields = civicrm_api3( 'Contact', 'getsingle', $params );

// Custom fields
$c_fields = CiviCRM_Caldera_Forms_Helper::get_contact_custom_fields();
$c_fields = implode( ',', CiviCRM_Caldera_Forms_Helper::get_contact_custom_fields() );

$c_fields_string = '';
foreach ( $c_fields as $key => $value ) {
$c_fields_string .= $key . ',';
}
if ( empty( $c_fields ) ) return $fields;

$custom_fields = civicrm_api3( 'Contact', 'getsingle', array(
'sequential' => 1,
'id' => $cid,
'return' => $c_fields_string,
));
$params['return'] = $c_fields;
$custom_fields = civicrm_api3( 'Contact', 'getsingle', $params );

return array_merge( $fields, $custom_fields );

Expand Down

0 comments on commit d575c17

Please sign in to comment.