$campaignId = $params['campaign_id'] ?? $form->_values['campaign_id'] ?? NULL;
$recurParams['campaign_id'] = $campaignId;
$recurring = CRM_Contribute_BAO_ContributionRecur::add($recurParams);
- if (is_a($recurring, 'CRM_Core_Error')) {
- CRM_Core_Error::displaySessionError($recurring);
- $urlString = 'civicrm/contribute/transact';
- $urlParams = '_qf_Main_display=true';
- if (get_class($form) == 'CRM_Contribute_Form_Contribution') {
- $urlString = 'civicrm/contact/view/contribution';
- $urlParams = "action=add&cid={$form->_contactID}";
- if ($form->_mode) {
- $urlParams .= "&mode={$form->_mode}";
- }
- }
- CRM_Utils_System::redirect(CRM_Utils_System::url($urlString, $urlParams));
- }
$form->_params['contributionRecurID'] = $recurring->id;
return $recurring->id;