Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created October 9, 2023 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewlimaza/3051f7cea4acde95426189c447519c27 to your computer and use it in GitHub Desktop.
Save andrewlimaza/3051f7cea4acde95426189c447519c27 to your computer and use it in GitHub Desktop.
Make bstate field optional for Paid Memberships Pro checkout
<?php
/**
* Remove the bstate requirement from billing fields generated by PMPro or Address for Free Levels Add On
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_remove_bstate_required( $pmpro_required_billing_fields ){
//remove field ID's from array to make fields required
$remove_field = array('bstate');
//loop through the $remove_field array and unset each billing field to make it optional.
foreach($remove_field as $field){
unset($pmpro_required_billing_fields[$field]);
}
return $pmpro_required_billing_fields;
}
add_filter('pmpro_required_billing_fields', 'my_pmpro_remove_bstate_required', 50 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment