Skip to content

Instantly share code, notes, and snippets.

@kimwhite
Last active December 16, 2019 15:18
Show Gist options
  • Save kimwhite/c8c023f7c3ccf4029e4a5c9a8612ce01 to your computer and use it in GitHub Desktop.
Save kimwhite/c8c023f7c3ccf4029e4a5c9a8612ce01 to your computer and use it in GitHub Desktop.
<?
/*
* Register Helper fields for Mobile Phone and Birthdate.
*
*/
// Add All the content below this line to your to your PMPro Customizations page.
// We have to put everything in a function called on init, so we are sure Register Helper is loaded.
function my_pmprorh_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
// Define the fields.
$fields = array();
$fields[] = new PMProRH_Field(
'date_of_birth', // input name, will also be used as meta key
'date', // type of field
array(
'label' => 'Date Of Birth', // custom field label
'size' => 40, // input size
'profile' => true, // show in user profile
'required' => false, // make this field required
'memberslistcsv' => true, // addes this to csv export
'addmember' => true, // include when using add member from admin
)
);
$fields[] = new PMProRH_Field(
'mobile_phone_number', // input name, will also be used as meta key
'text', // type of field
array(
'label' => 'Mobile Phone', // custom field label
'size' => 40, // input size
'class' => 'mobilephone', // custom class
'profile' => true, // show in user profile
'required' => false, // make this field required
'memberslistcsv' => true, // addes this to csv export
'addmember' => true, // include when using add member from admin
)
);
// 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