Forked from pbrocks/pmpro-billing-fields-to-profile.php
Last active
January 4, 2019 23:26
-
-
Save itsjusteileen/e99a33cd33319448667641fa79a9999d to your computer and use it in GitHub Desktop.
Add the billing fields created by Paid Memberships Pro to your user and BuddyPress profile and inclusion in the Members List CSV export
This file contains hidden or 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
<?php | |
/** | |
* Plugin Name: PMPro Profile Fields | |
* | |
* Add PMPro billing fields to the WordPress and BuddyPress user profiles | |
* | |
* You must have installed both Paid Memberships Pro and the PMPro Register Helper plugins | |
* | |
* https://github.com/strangerstudios/pmpro-register-helper | |
*/ | |
function add_billing_fields_to_profile() { | |
global $pmpro_countries; | |
// 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' => 'Address 1', | |
'buddypress' => 'Address 1', | |
'size' => 40, | |
'memberslistcsv' => true, | |
'required' => false, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'pmpro_baddress2', | |
'text', | |
array( | |
'label' => 'Address 2', | |
'buddypress' => 'Address 2', | |
'size' => 40, | |
'memberslistcsv' => true, | |
'required' => false, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'pmpro_bcity', | |
'text', | |
array( | |
'label' => 'City', | |
'buddypress' => 'City', | |
'size' => 40, | |
'memberslistcsv' => true, | |
'required' => false, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'pmpro_bstate', | |
'text', | |
array( | |
'label' => 'State', | |
'buddypress' => 'State', | |
'size' => 10, | |
'memberslistcsv' => true, | |
'required' => false, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'pmpro_bzipcode', | |
'text', | |
array( | |
'label' => 'Postal Code', | |
'buddypress' => 'Postal Code', | |
'size' => 20, | |
'memberslistcsv' => true, | |
'required' => false, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'pmpro_bcountry', | |
'select', | |
array( | |
'label' => 'Billing Country', | |
'buddypress' => 'Billing Country', | |
'memberslistcsv' => true, | |
'required' => false, | |
'options' => array_merge( array( '' => '- choose one -' ), array( $pmpro_countries ) ), | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'pmpro_bphone', | |
'text', | |
array( | |
'label' => 'Billing Phone', | |
'buddypress' => 'Billing Phone', | |
'size' => 40, | |
'memberslistcsv' => true, | |
'required' => false, | |
) | |
); | |
// add the fields | |
foreach ( $fields as $field ) { | |
pmprorh_add_registration_field( 'profile', $field ); | |
} | |
} | |
add_action( 'init', 'add_billing_fields_to_profile' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment