Last active
October 9, 2023 11:27
-
-
Save andrewlimaza/605a29ff9ee0701894e6e7bb90d10c95 to your computer and use it in GitHub Desktop.
Make billing details optional for Paid Memberships Pro
This file contains hidden or 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 | |
//add lines 4-15 to your custom plugin or functions.php of your active theme | |
function pmpro_remove_bfields( $pmpro_required_billing_fields ){ | |
//remove field ID's from array to make fields required | |
$remove_field = array('bfirstname', 'blastname', 'baddress1', 'bcity', 'bstate', 'bcountry', 'bzipcode', 'bphone', 'bemail', 'bconfirmemail'); | |
//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', 'pmpro_remove_bfields'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the "Paid Memberships Pro - Address For Free Levels Add On", you may need to increase the priority of the code to be 50+
For example:
add_filter('pmpro_required_billing_fields', 'pmpro_remove_bfields', 50);