Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save femiyb/7f847ea123ee49ade70b1440b611ea20 to your computer and use it in GitHub Desktop.
Save femiyb/7f847ea123ee49ade70b1440b611ea20 to your computer and use it in GitHub Desktop.
Hide Paid Memberships Pro billing address fields and make them optional. Meant to be used with the Braintree gateway.
/*
Hide billing address fields and make them optional.
Meant to be used with the Braintree Payments gateway.
*/
//css to hide the fields
function wp_head_hide_billing_fields()
{
global $post, $pmpro_pages;
if(empty($pmpro_pages) || (!is_page($pmpro_pages['checkout']) && !is_page($pmpro_pages['billing'])))
return;
?>
<style>
#pmpro_billing_address_fields div.pmpro_checkout-field.pmpro_checkout-field-bzipcode {
display: none;
}
#pmpro_billing_address_fields div.pmpro_checkout-field.pmpro_checkout-field-bphone {
display: none;
}
#pmpro_billing_address_fields div.pmpro_checkout-field.pmpro_checkout-field-baddress1 {
display: none;
}
#pmpro_billing_address_fields div.pmpro_checkout-field.pmpro_checkout-field-baddress2 {
display: none;
}
</style>
<?php
}
add_action('wp_head', 'wp_head_hide_billing_fields');
//make sure they aren't required
function my_pmpro_required_billing_fields($fields)
{
if(is_array($fields))
{
unset($fields['baddress1']);
unset($fields['baddress2']);
unset($fields['bzipcode']);
unset($fields['bphone']);
}
return $fields;
}
add_action('pmpro_required_billing_fields', 'my_pmpro_required_billing_fields');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment