1

We're running on Drupal 7.69 and Civi 5.13.x.

Is there a way to have the option to autorenew ticked by default through configuration?

See image below: enter image description here

2
  • So you always want the General membership to auto-renew? Or just check box on initial load and than let user un-select it if they wont like to auto-renew? Commented Apr 7, 2020 at 2:50
  • This one Pradeep - "just check box on initial load and than let user un-select it if they wont like to auto-renew".
    – P Joseph
    Commented Apr 7, 2020 at 3:13

2 Answers 2

2

For a site using CiviCRM profiles you can opt to use Joinery's Profile Conditionals extension and adapt the conditions to which you want this behavior to occur.

For it be checked with any price field selected, an example is below:

<?php
        
$civicrm_setting['com.joineryhq.profcond']['com.joineryhq.profcond']['contribution']['all'] = array(
          '01_auto_renew_is_checked' => array(
            'conditions' => array(
              'all_of' => array(
                array(
                  'selector' => 'input[name="price_7"]',
                    'op' => 'is_checked',
                    ),
                  ),
                ),
                'states' => array (
                  'pass' => array (
                    'selectors'  => array(
                      'input#auto_renew[type="checkbox"]' => array (
                        'properties' => array('checked' => TRUE),
                      ),
                    ),
                  ),
                  'fail' => array (
                    'selectors'  => array(
                      'input#auto_renew[type="checkbox"]' => array (
                        'properties' => array('checked' => FALSE),
                      ),
                    ),
                  ),
                ),
              ),
            );

Change out the price field (price_7) with yours. There are many ways to change the conditions based on your use case, you can find instructions on those options here.

I put this in it's own profcond.settings.php file in case you make a syntax error and want to quickly deactivate the conditionals to prevent it from breaking CiviCRM. Add include __DIR__ . '/profcond.settings.php'; to civicrm.settings.php file for this setup.

Also noting that recently there was a change in core that displays / unchecks the "Please renew my membership automatically" option when selecting a price option so using the "onload" option exclusively no longer works (tested 5.65 where that last worked).

1

Unless things have changed I believe this requires a customisation. We did one a while back. I will check what effort is involved in getting it extracted in to an extension if there is not one 'out there'.

1
  • Hmm looks like the work we did doesn't properly deal with switching between Pay Later and CC. We could get this sorted if you are interested. PM me if you want an estimate. Don't expect it will take much
    – petednz - fuzion
    Commented Apr 7, 2020 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.