Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MaryOJob/58a64d35237a2800110c7126ee928dcd to your computer and use it in GitHub Desktop.
Save MaryOJob/58a64d35237a2800110c7126ee928dcd to your computer and use it in GitHub Desktop.
Makes All billing Address Fields Not Required At checkout.
<?php // do not copy this line
/**
* This recipe makes all billing fields on the checkout page not required
*
* Note: Make sure your Gateway doesn't require these fields.
*
* 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_pmpro_not_required_billing_fields( $fields ) {
if ( is_array( $fields ) ) {
unset( $fields['bfirstname'] );
unset( $fields['blastname'] );
unset( $fields['baddress1'] );
unset( $fields['baddress2'] );
unset( $fields['bcity'] );
unset( $fields['bstate'] );
unset( $fields['bzipcode'] );
unset( $fields['bcountry'] );
unset( $fields['bphone'] );
}
return $fields;
}
//run it later in the queue if necessary if other plugins or code sets fields required, e.g. change 50 to a higher number.
add_action( 'pmpro_required_billing_fields', 'my_pmpro_not_required_billing_fields', 50, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment