Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewlimaza/e17a82948542e0a036446ee15b1bf014 to your computer and use it in GitHub Desktop.
Save andrewlimaza/e17a82948542e0a036446ee15b1bf014 to your computer and use it in GitHub Desktop.
Add billing fields to Add Member Settings
<?php
/*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This will add billing fields to Add Member and the user's profile page.
*/
function add_billing_fields_to_add_member_profile() {
//check for register helper
if(!function_exists("pmprorh_add_registration_field"))
return;
//define the fields
$fields = array();
$fields[] = new PMProRH_Field("pmpro_baddress1", "text", array("label"=>"Billing Address 1", "size"=>40, "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMProRH_Field("pmpro_baddress2", "text", array("label"=>"Billing Address 2", "size"=>40, "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMProRH_Field("pmpro_bcity", "text", array("label"=>"Billing City", "size"=>40, "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMProRH_Field("pmpro_bstate", "text", array("label"=>"Billing State", "size"=>10, "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMProRH_Field("pmpro_bzipcode", "text", array("label"=>"Billing Postal Code", "size"=>10, "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMProRH_Field("pmpro_bcountry", "text", array("label"=>"Billing Country", "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMProRH_Field("pmpro_bphone", "text", array("label"=>"Billing Phone", "size"=>40, "profile"=>true, "required"=>false, "addmember" => true));
//add the fields into a new checkout_boxes are of the checkout page
foreach($fields as $field)
pmprorh_add_registration_field("profile", $field);
}
add_action("init", "add_billing_fields_to_add_member_profile");
@gausam
Copy link

gausam commented Aug 7, 2020

To show the country as a dropdown, use this modified version - https://gist.github.com/gausam/04e4b02eb239bd94e68a4718de2c85dc.

@ipokkel
Copy link

ipokkel commented Dec 8, 2020

To include billing First and last names - https://gist.github.com/ipokkel/08cc6d914947ca2d37d86acb4f599c79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment