Created
March 13, 2019 08:37
-
-
Save ipokkel/b328ad8aad5e80bb4f14d5f41fb9dae3 to your computer and use it in GitHub Desktop.
Example for adding State, City and Phone number fields using the PMPro Customizations plugin
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
<?php | |
/* | |
Plugin Name: PMPro Customizations | |
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/ | |
Description: Customizations for my Paid Memberships Pro Setup | |
Version: .1 | |
Author: Paid Memberships Pro | |
Author URI: https://www.paidmembershipspro.com | |
*/ | |
//Now start placing your customization code below this line | |
function my_pmprorh_init() | |
{ | |
//don't break if Register Helper is not loaded | |
if(!function_exists( 'pmprorh_add_registration_field' )) { | |
return false; | |
} | |
$fields = array(); | |
$fields[] = new PMProRH_Field( | |
'state', | |
'text', | |
array( | |
'label' => 'State', | |
'required' => true, // make this field required | |
'profile' => true, // show in user profile | |
// 'memberslistcsv' => true, // Uncomment to include in Memberlist CSV | |
// "addmember" => true, // Uncomment if using the Admin Add Member plugin | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'City', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'label' => 'City', // custom field label | |
'required' => true, // make this field required | |
'profile' => true, // show in user profile | |
// 'memberslistcsv' => true, // Uncomment to Include in Member List CSV Export | |
// 'addmember' => true, // Uncomment to display in Add Member | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'phone_number', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'label' => 'Phone Number', // custom field label | |
'required' => true, // make this field required | |
'profile' => true, // show in user profile | |
// 'memberslistcsv' => true, // Uncomment to Include in Member List CSV Export | |
// 'addmember' => true, // Uncomment to display in Add Member | |
) | |
); | |
//add the fields into a new checkout_boxes are of the checkout page | |
foreach($fields as $field) | |
pmprorh_add_registration_field( | |
'checkout_boxes', // location on checkout page | |
$field // PMProRH_Field object | |
); | |
//that's it. see the PMPro Register Helper readme for more information and examples. | |
} | |
add_action( 'init', 'my_pmprorh_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment