Skip to content

Instantly share code, notes, and snippets.

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 femiyb/395e44ecf870ef58803e52c1bd1872ca to your computer and use it in GitHub Desktop.
Save femiyb/395e44ecf870ef58803e52c1bd1872ca to your computer and use it in GitHub Desktop.
PMPro - Remove state from required billing fields and hide it the state field.
<?php // Do NOT copy this line
/* Copy from below this line */
/*
Remove state from required billing fields and hide it the state field.
*/
// Unset state
add_action( 'pmpro_required_billing_fields', 'my_pmpro_required_billing_fields' );
function my_pmpro_required_billing_fields( $fields ) {
if ( is_array( $fields ) ) {
// unset( $fields['bfirstname'] );
// unset( $fields['blastname'] );
// unset( $fields['baddress1'] );
// unset( $fields['bcity'] );
unset( $fields['bstate'] );
// unset( $fields['bcountry'] );
// unset( $fields['bzipcode'] );
unset( $fields['bphone'] );
// unset( $fields['bemail'] );
// unset( $fields['bconfirmemail'] );
}
return $fields;
}
/*
// Hide field by adding CSS to the page head.
add_action( 'wp_head', 'wp_head_hide_billing_state_field' );
function wp_head_hide_billing_state_field() {
global $pmpro_pages;
if ( empty( $pmpro_pages ) || ( ! is_page( $pmpro_pages['checkout'] ) && ! is_page( $pmpro_pages['billing'] ) ) ) {
return;
}
?>
<style>
div.pmpro_checkout-field-bstate {
display: none;
}
</style>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment