Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CrandellWS/9a9c82ea5b99cd531e0ec74eb39409b6 to your computer and use it in GitHub Desktop.
Save CrandellWS/9a9c82ea5b99cd531e0ec74eb39409b6 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.
add_action('pmpro_checkout_before_submit_button', 'my_pmp_jquery');
function my_pmp_jquery() {
global $current_user;
get_currentuserinfo();
if ($current_user->user_login) {
//script will hide billing fields and prefill name and email from WP account
?>
<script>
jQuery( document ).ready(function($) {
var fname = '<?php echo $current_user->user_firstname; ?>';
var lname = '<?php echo $current_user->user_lastname; ?>';
var user_email = '<?php echo $current_user->user_email; ?>';
//console.log(user_email);
$('#bfirstname').val(fname);
$('#blastname').val(lname);
$('#baddress1').parent().hide();
$('#baddress2').parent().hide();
$('#bcity').parent().hide();
$('#bstate').parent().hide();
$('#bzipcode').parent().hide();
$('#bcountry').parent().hide();
$('select[name=bcountry]').parent().hide(); //no id in some versions
$('#bphone').parent().hide();
$('#bemail').prop('disabled', 'true'); //disable changing email here if you know they are logged in
}); //ready
</script>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment