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 ipokkel/2c0033e9a1498fef758eaf44dad124d4 to your computer and use it in GitHub Desktop.
Save ipokkel/2c0033e9a1498fef758eaf44dad124d4 to your computer and use it in GitHub Desktop.
Remove shipping phone field from PMPro checkout
<?php
/**
* This recipe makes the shipping phone field, sphone, optional and hides the field on the checkout form.
* default user account email on renewal.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_remove_phone_shipping( $fields ) {
// make optional
unset( $fields['sphone'] );
return $fields;
}
add_filter( 'pmproship_required_shipping_fields', 'pmpro_remove_phone_shipping', 10, 1 );
function wp_head_hide_sphone_field() {
// bail if shipping address add on not active
if ( ! defined( 'PMPRO_SHIPPING_VERSION' ) ) {
return;
}
global $pmpro_pages;
if ( ! is_admin() && ! empty( $pmpro_pages ) && ( is_page( $pmpro_pages['checkout'] ) || is_page( $pmpro_pages['billing'] ) ) ) {
?>
<style>
#shipping-fields .pmpro_checkout-field-sphone {
display: none;
}
</style>
<?php
}
}
add_action( 'wp_head', 'wp_head_hide_sphone_field' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment