Have a question about CiviCRM? Get it answered quickly at the new CiviCRM Stack Exchange Q+A siteThis forum was archived on 25 November 2017. Learn more.How to get involved.What to do if you think you've found a bug.
function dgg_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) { for ($i=1; $i <= count($membershipTypeValues); $i++) { if ($membershipTypeValues[$i]['name'] == 'General') { $membershipTypeValues[$i]['minimum_fee'] = "5.55"; } if ($membershipTypeValues[$i]['name'] == 'Student') { $membershipTypeValues[$i]['minimum_fee'] = "2.22"; } } }
CRM_Core_Error::debug('label', $varOrArrayToDump);
// reduce the price of renewals by the value set in the admin controlfunction membershipRenewal_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) { for ($i=1; $i < count($membershipTypeValues); $i++) { if ($membershipTypeValues[$i]['name'] == '12 month Australian') { $membershipTypeValues[$i]['minimum_fee'] = $membershipTypeValues[$i]['minimum_fee'] - variable_get('membershipRenewal_maxdisp', 20); } if ($membershipTypeValues[$i]['name'] == '24 month Australian') { $membershipTypeValues[$i]['minimum_fee'] = $membershipTypeValues[$i]['minimum_fee'] - variable_get('membershipRenewal_maxdisp', 20); } if ($membershipTypeValues[$i]['name'] == '12 month Concession') { $membershipTypeValues[$i]['minimum_fee'] = $membershipTypeValues[$i]['minimum_fee'] - variable_get('membershipRenewal_maxdisp', 20); } } }
for ($i=1; $i <= count($membershipTypeValues); $i++) {
I've attached a screenshot of the confirmation page - showing the modified fee of $5.55.
CRM_Core_Error::debug('membership Type Values', $membershipTypeValues);
membership Type ValuesArray( [1] => Array ( [id] => 1 [minimum_fee] => 45 [name] => 12 month Australian [is_active] => 1 [description] => [contribution_type_id] => 2 ) [2] => Array ( [id] => 2 [minimum_fee] => 92 [name] => 24 month Australian [is_active] => 1 [description] => [contribution_type_id] => 2 ) [3] => Array ( [id] => 3 [minimum_fee] => 30 [name] => 12 month Concession [is_active] => 1 [description] => [contribution_type_id] => 2 ))membership Type ValuesArray( [2] => Array ( [id] => 2 [minimum_fee] => 112.00 [name] => 24 month Australian [is_active] => 1 [description] => [contribution_type_id] => 2 ))
// reduce the price of renewals by the value set in the admin controlfunction membershipRenewal_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) { foreach ( $membershipTypeValues as &$values) { if ($values['name'] == '12 month Australian') { $values['minimum_fee'] = $values['minimum_fee'] - variable_get('membershipRenewal_maxdisp', 20); } if ($values['name'] == '24 month Australian') { $values['minimum_fee'] = $values['minimum_fee'] - variable_get('membershipRenewal_maxdisp', 20); } if ($values['name'] == '12 month Concession') { $values['minimum_fee'] = $values['minimum_fee'] - variable_get('membershipRenewal_maxdisp', 20); } } }
function mymodule_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) { foreach ( $membershipTypeValues as &$values) { if ( $values['name'] == 'General') { $values['minimum_fee'] = "5.55"; } if ( $values['name'] == 'Student') { $values['minimum_fee'] = "2.22"; } }}
<?phpmembershipRenewalContentArray; require_once ('/home/humanmil/public_html/drupal/sites/all/civicrm.settings.php'); require_once ($civicrm_root . '/CRM/Core/Config.php'); $config =& CRM_Core_Config::singleton( ); require_once "api/v2/Contribute.php"; require_once "api/v2/Membership.php";// reduce the price of renewals by the value set in the admin controlfunction membershipRenewal_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) { // get all memberships $membershipTypes = _civimember_roles_get_data('types'); // loop through the membership array and fetch renewal values foreach ( $membershipTypeValues as &$values) { // loop through membership types for ($i=1; $i<=count($membershipTypes); $i++) { // find membership type in array // if a renewal fee exists, use that. Otherwise use the full fee if (array_search($values['name'], $membershipTypes[$i])) { $fieldName = "membershipRenewal_" . str_replace(" ", "_", $membershipTypes[$i][1]); $values['minimum_fee'] = variable_get($fieldName, $membershipTypes[$i][2]); } } } }// admin control panelfunction membershipRenewal_admin() { // get all membership types $membershipTypes = _civimember_roles_get_data('types'); // loop through membership types, and create a field to add a renewal price for ($i=1; $i<=count($membershipTypes); $i++) { $fieldName = "membershipRenewal_" . str_replace(" ", "_", $membershipTypes[$i][1]); $form[$fieldName] = array( '#type' => 'textfield', '#title' => t('Renewal price of <i>' . $membershipTypes[$i][1] . '</i> (new membership is $' . $membershipTypes[$i][2] . ')'), '#default_value' => variable_get($fieldName, $membershipTypes[$i][2]), '#size' => 2, '#maxlength' => 5, '#description' => t("Price to renew"), '#required' => TRUE, ); } // return the form return system_settings_form($form);}// validate admin inputfunction membershipRenewal_admin_validate($form, &$form_state) { // todo: validate input }// display link in module menufunction membershipRenewal_menu() { $items = array(); $items['admin/settings/membershipRenewal'] = array( 'title' => 'Membership Renewal Settings', 'description' => 'Setting for when subscribers renew their memberships', 'page callback' => 'drupal_get_form', 'page arguments' => array('membershipRenewal_admin'), 'access arguments' => array('access administration pages'), 'type' => MENU_NORMAL_ITEM, ); return $items;}// define access permissionsfunction membershipRenewal_perm() { return array('access membershipRenewal content');} /** * This function returns an array of either membership types or status rules depending on the $type param. * Function is from civimember_roles module */function _civimember_roles_get_data($type) { switch ($type) { case 'status': $sql = 'SELECT id, name FROM civicrm_membership_status WHERE domain_id = %1;'; break; case 'types': $sql = 'SELECT id, name, minimum_fee FROM civicrm_membership_type WHERE domain_id = %1;'; break; default: $sql = ''; drupal_set_message(t('Invalid parameter was given to _civimember_roles_get_data(). Param: "%invalid".', array('%invalid' => $type))); break; } $params = array(1 => array(CIVICRM_DOMAIN_ID, 'Integer')); $dao =& CRM_Core_DAO::executeQuery($sql, $params); $result = array(); while ($dao->fetch()) { $result[$dao->id] = array($result[$dao->id], $dao->name, $dao->minimum_fee); } unset($dao); if (empty($result)) { drupal_set_message(t('CiviMember Membership Types or Status Rules have not been configured. Please do so on the "Administer CiviCRM" page.'), $type = 'error'); } return $result;}
function membershipRenewal_civicrm_postProcess( $formName, &$form ) { if ( is_a( $form, 'CRM_Contribute_Form_Contribution_Main' ) ) { //CRM_Core_Error::debug('form variables', CRM_Contribute_Form_Contribution_Main::_values); CRM_Core_Error::debug('form variables', $form); }}
function membershipRenewal_civicrm_postProcess( $formName, &$form ) { if ( is_a( $form, 'CRM_Contribute_Form_Contribution_Main' ) ) { CRM_Core_Error::debug('form values', $form->_values); }}
function membershipRenewal_civicrm_postProcess( $formName, &$form ) { if ( is_a( $form, 'CRM_Contribute_Form_Contribution_Main' ) ) { CRM_Core_Error::debug('form values', $form->getVar('_values')); }}
$form->setVar('_values['foo']', 'bar')
$values = $form->getVar( '_values' ); $values['foo'] = 'bar'; $form->setVar( '_values', $values );