Skip to content

Instantly share code, notes, and snippets.

@eighty20results
Last active February 16, 2016 14:35
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 eighty20results/74c53c19fb762b5f215d to your computer and use it in GitHub Desktop.
Save eighty20results/74c53c19fb762b5f215d to your computer and use it in GitHub Desktop.
Add billing info to the users profile
<?php
/*
Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins.
*/
function my_show_pmpro_address_fields_in_profile()
{
//require PMPro and PMPro Register Helper
if(!defined('PMPRO_VERSION') || !defined('PMPRORH_VERSION'))
return;
$address_fields = array(
'pmpro_bfirstname'=>'First Name',
'pmpro_blastname'=>'Last Name',
'pmpro_baddress1'=>'Address 1',
'pmpro_baddress2'=>'Address 2',
'pmpro_bcity'=>'City',
'pmpro_bstate'=>'State',
'pmpro_bzipcode'=>'Zipcode',
'pmpro_bphone'=>'Phone',
);
//define the fields
$fields = array();
foreach($address_fields as $name=>$label)
{
$fields[] = new PMProRH_Field(
$name, // input name, will also be used as meta key
"text", // type of field
array(
"label"=>$label,
"size"=>40, // input size
"profile"=>true, // show in user profile => "only", Show on checkout page too => true, show for admins only => 'only_admin'
));
}
//add a new checkout box with label
pmprorh_add_checkout_box("billing_mailing_address", "Billing/Mailing Address");
//add the fields into a new checkout_boxes are of the checkout page
foreach($fields as $field)
pmprorh_add_registration_field(
"billing_mailing_address", // location on checkout page
$field // PMProRH_Field object
);
}
add_action('init', 'my_show_pmpro_address_fields_in_profile');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment