Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active October 9, 2023 11:27
Show Gist options
  • Save andrewlimaza/605a29ff9ee0701894e6e7bb90d10c95 to your computer and use it in GitHub Desktop.
Save andrewlimaza/605a29ff9ee0701894e6e7bb90d10c95 to your computer and use it in GitHub Desktop.
Make billing details optional for Paid Memberships Pro
<?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');
@andrewlimaza
Copy link
Author

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment