Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Show address fields for free levels also with Paid Memberships Pro.
Plugin Name: PMPro Address For Free Levels
Plugin URI:
Description: Show address fields for free levels also with Paid Memberships Pro
Version: .2
Author: Stranger Studios
Author URI:
Show address fields for free levels too.
Add this code to your active theme's functions.php or a custom plugin.
//keep address fields shown on checkout page
function my_pmpro_checkout_boxes_require_address()
var pmpro_show_billing_address_fields_timer;
function showBillingAddressFields()
pmpro_show_billing_address_fields_timer = setTimeout(function(){showBillingAddressFields();}, 200);
jQuery(document).ready(function() {
//show it and keep showing it
//remove billing from address title if the level is free
global $pmpro_level;
//change heading
jQuery('#pmpro_billing_address_fields th').html('Address');
add_action("pmpro_checkout_boxes", "my_pmpro_checkout_boxes_require_address");
//make sure address fields are required
function my_pmpro_required_user_fields($fields)
global $bfirstname, $blastname, $baddress1, $bcity, $bstate, $bzipcode, $bcountry, $bphone, $bemail;
$fields["bfirstname"] = $bfirstname;
$fields["blastname"] = $blastname;
$fields["baddress1"] = $baddress1;
$fields["bcity"] = $bcity;
$fields["bstate"] = $bstate;
$fields["bzipcode"] = $bzipcode;
$fields["bphone"] = $bphone;
$fields["bemail"] = $bemail;
$fields["bcountry"] = $bcountry;
return $fields;
add_action("pmpro_required_user_fields", "my_pmpro_required_user_fields");
* Save billing fields when using PayPal
function my_pmpro_paypalexpress_session_vars() {
$_SESSION['bfirstname'] = $_REQUEST['bfirstname'];
$_SESSION['blastname'] = $_REQUEST['blastname'];
$_SESSION['baddress1'] = $_REQUEST['baddress1'];
$_SESSION['baddress2'] = $_REQUEST['baddress2'];
$_SESSION['bcity'] = $_REQUEST['bcity'];
$_SESSION['bstate'] = $_REQUEST['bstate'];
$_SESSION['bzipcode'] = $_REQUEST['bzipcode'];
$_SESSION['bphone'] = $_REQUEST['bphone'];
$_SESSION['bemail'] = $_REQUEST['bemail'];
$_SESSION['bcountry'] = $_REQUEST['bcountry'];
add_action('pmpro_paypalexpress_session_vars', 'my_pmpro_paypalexpress_session_vars');
//load vars back into $_REQUEST
function my_init() {
if(!empty($_REQUEST['review']) && !empty($_REQUEST['token'])) {
$_REQUEST['bfirstname'] = $_SESSION['bfirstname'];
$_REQUEST['blastname'] = $_SESSION['blastname'];
$_REQUEST['baddress1'] = $_SESSION['baddress1'];
$_REQUEST['baddress2'] = $_SESSION['baddress2'];
$_REQUEST['bcity'] = $_SESSION['bcity'];
$_REQUEST['bstate'] = $_SESSION['bstate'];
$_REQUEST['bzipcode'] = $_SESSION['bzipcode'];
$_REQUEST['bphone'] = $_SESSION['bphone'];
$_REQUEST['bemail'] = $_SESSION['bemail'];
$_REQUEST['bcountry'] = $_SESSION['bcountry'];
add_action('init', 'my_init');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment