Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ideadude/ebf16c77c2575309576507c8021101c6 to your computer and use it in GitHub Desktop.
Save ideadude/ebf16c77c2575309576507c8021101c6 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("pmpro_add_user_field")) // pmprorh_add_registration_field
return;
//define the fields
$fields = array();
$fields[] = new PMPro_Field("pmpro_baddress1", "text", array("label"=>"Billing Address 1", "size"=>40, "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMPro_Field("pmpro_baddress2", "text", array("label"=>"Billing Address 2", "size"=>40, "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMPro_Field("pmpro_bcity", "text", array("label"=>"Billing City", "size"=>40, "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMPro_Field("pmpro_bstate", "text", array("label"=>"Billing State", "size"=>10, "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMPro_Field("pmpro_bzipcode", "text", array("label"=>"Billing Postal Code", "size"=>10, "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMPro_Field("pmpro_bcountry", "text", array("label"=>"Billing Country", "profile"=>true, "required"=>false, "addmember" => true));
$fields[] = new PMPro_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)
pmpro_add_user_field("profile", $field);
}
add_action("init", "add_billing_fields_to_add_member_profile");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment