Forked from andrewlimaza/remove-shipping-phone-field-pmpro.php
Last active
June 25, 2020 15:37
-
-
Save ipokkel/2c0033e9a1498fef758eaf44dad124d4 to your computer and use it in GitHub Desktop.
Remove shipping phone field from PMPro checkout
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 | |
/** | |
* 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