Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travislima/a82b004294e028cee8fff6a385241f6f to your computer and use it in GitHub Desktop.
Save travislima/a82b004294e028cee8fff6a385241f6f to your computer and use it in GitHub Desktop.
Checkbox example for Register Helper PMPro
<?php
/**
* Add the following code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations
* In this example you will learn how to add 3 checkboxes to Paid Memberships Pro Checkout page.
*/
function rh_fields_example_checkbox()
{
//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(
'option1', // input name, will also be used as meta key
'checkbox', // type of field
array(
'label' => 'Option 1',
'profile' => 'true',
)
);
$fields[] = new PMProRH_Field(
'option2', // input name, will also be used as meta key
'checkbox', // type of field
array(
'label' => 'Option 2',
'profile' => 'true',
)
);
$fields[] = new PMProRH_Field(
'option3', // input name, will also be used as meta key
'checkbox', // type of field
array(
'label' => 'Option 3',
'profile' => 'true',
)
);
//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', 'rh_fields_example_checkbox' );
@laurenhagan0306
Copy link

This recipe is included in the blog post on "How to add a checkbox-type field to your checkout page using Register Helper." at Paid Memberships Pro here: https://www.paidmembershipspro.com/how-to-add-a-checkbox-type-field-to-your-checkout-page-using-register-helper/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment