Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dwanjuki/24eb7fa6cd9d26381e0a3920bfcc3862 to your computer and use it in GitHub Desktop.
Save dwanjuki/24eb7fa6cd9d26381e0a3920bfcc3862 to your computer and use it in GitHub Desktop.
Remove Auto Renewal Checkbox if Pay by Check is selected
<?php
/**
* Remove Auto Renewal Checkbox if Pay by Check is selected
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_hide_arc_if_pbc_selected_script() {
if ( function_exists( 'pmpro_is_checkout' ) && pmpro_is_checkout() && function_exists( 'pmproarc_pmpro_checkout_boxes' ) && function_exists( 'pmpropbc_checkout_boxes' ) ) {
?>
<script>
jQuery(document).ready(function(){
jQuery('#pmpro_payment_method input').on('click', function(){
if ( jQuery(this).val() == 'check' ) {
jQuery('#pmpro_autorenewal_checkbox').hide();
jQuery('#pmpro_autorenewal_checkbox #autorenew').prop('checked', false);
} else {
jQuery('#pmpro_autorenewal_checkbox').show();
}
});
});
</script>
<?php
}
}
add_action( 'wp_footer', 'my_hide_arc_if_pbc_selected_script' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment