I'm developing a little wordpress plugin which creates a custom post type with a custom field where I would like to store an ID of one of the active contribution page of CiviCRM in order to associate this content with the contribution page information.
This very same code works in theme files but fails when is used in plugin files, breaking the site.
function get_contribution_info($f_type){
$params = array(
'version' => 3,
'financial_type_id' => $f_type,
'is_active' => '1'
);
try{
$result = civicrm_api3('contribution_page', 'get', $params);
} catch (CiviCRM_API3_Exception $e) {
// handle error here
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
}
return $result[values];
}
$get_contrib = get_contribution_data( '1' );
$contributions = array();
$i = 0;
foreach($get_contrib as $c) {
$contributions[$i]['label'] = $c['title'];
$contributions[$i]['value'] = $c['id'];
$i++;
}
I've tried to add a require_once
the class.api.php
without positive results.
Thanks in advance for your help!