Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Last active February 27, 2019 18:07
Show Gist options
  • Save ipokkel/3c9e38aad504fb9936cc1fc5b1419c5f to your computer and use it in GitHub Desktop.
Save ipokkel/3c9e38aad504fb9936cc1fc5b1419c5f to your computer and use it in GitHub Desktop.
PMPro Customization: Register Helper - Add date of birth date picker to checkout
<?php
/**
* PMPro Customization: Register Helper - Add date of birth date picker to checkout
*/
//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
'class' => 'date', // date class
'profile' => true, // show in user profile
'required' => true, // make this field required
// 'addmember' => true, // Uncomment to display in Add Member
// 'memberslistcsv' => true, // Uncomment to Include in Member List CSV Export
)
);
//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