Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Step 2 - Register Helper: A step-by-step guide on creating custom fields.
<?php //Do not copy this tag.
/**
* Add custom fields to Paid Memberships Pro checkout page.
* Must have PMPro & Register Helper Add On installed and activated to work.
* Add this code to a PMPro Customizations Plugin or Code Snippets plugin.
*/
function pmpro_add_fields_to_checkout(){
//don't break if Register Helper is not loaded
if(!function_exists( 'pmprorh_add_registration_field' )) {
return false;
}
$fields = array();
$fields[] = new PMProRH_Field(
'company', // input name, will also be used as meta key
'text', // type of field
array(
'label' => 'Company', // custom field label
'profile' => true, // show in user profile
'required' => true, // make this field required
)
);
//add the fields to default forms
foreach($fields as $field){
pmprorh_add_registration_field(
'checkout_boxes', // location on checkout page
$field // PMProRH_Field object
);
}
}
add_action( 'init', 'pmpro_add_fields_to_checkout' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.