Last active
June 13, 2018 12:36
-
-
Save strangerstudios/2c7ef6d2989465c4ba54 to your computer and use it in GitHub Desktop.
Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins. | |
*/ | |
function show_pmpro_address_fields_on_edit_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"=>"only_admin", // show in user profile for admins | |
)); | |
} | |
//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', 'show_pmpro_address_fields_on_edit_profile'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Forked here: https://gist.github.com/ideadude/882da87a55ee99b666870dfe1cc7eeb5
(When we converted "strangerstudios" to an organization account, we lost the ability to edit these old gists. Any updates will be made to the fork under my personal "ideadude" account.)