Created
October 9, 2023 12:09
-
-
Save andrewlimaza/3051f7cea4acde95426189c447519c27 to your computer and use it in GitHub Desktop.
Make bstate field optional for Paid Memberships Pro checkout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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