Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.