Skip to content

Instantly share code, notes, and snippets.

@MaryOJob
Last active September 22, 2020 14:23
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 MaryOJob/8059564f59e9a8635cecf1e312c5673e to your computer and use it in GitHub Desktop.
Save MaryOJob/8059564f59e9a8635cecf1e312c5673e to your computer and use it in GitHub Desktop.
Add Custom Fields Example in a Checkbox Area with a Custom Name
<?php // Do not copy this line.
/**
* See the PMPro Register Helper readme for more information and examples: https://www.paidmembershipspro.com/documentation/register-helper-documentation/adding-fields/
* Please add the below code to your custom plugin or Code Snippets Plugin by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// We have to put everything in a function called on init, so we are sure Register Helper is loaded.
function pmpro_register_field_peakbagger_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
pmprorh_add_checkout_box( 'w9information', 'W-9 Information' );
// Define the fields.
$fields_w9information = array();
$fields_w9information[] = new PMProRH_Field(
'legalname',
'text',
array(
'label' => 'Legal Name',
'size' => 40,
'class' => 'legalname',
'profile' => true,
'levels' => 5, // show only to level 5 members checkout
'required' => true,
)
);
$fields_w9information[] = new PMProRH_Field(
'email_for_w9',
'text',
array(
'label' => 'Email for W-9 Information',
'size' => 40,
'class' => 'email_for_w9',
'profile' => true,
'levels' => 5, // show only to level 5 members checkout
'required' => true,
)
);
$fields_w9information[] = new PMProRH_Field(
'w9_form',
'file',
array(
'label' => 'Upload Filled W-9 Form',
'size' => 40,
'hint' => 'Click <a href="/affiliateform">here</a> to download W-9 form for your Affiliate Registration', // add the download link here on your site, it could also be /wp-content....
'class' => 'w9_form',
'profile' => true,
'levels' => 5, // show only to level 5 members checkout
'required' => true,
)
);
foreach ( $fields_w9information as $field ) {
pmprorh_add_registration_field(
'w9information',
$field
);
}
}
add_action( 'init', 'pmpro_register_field_peakbagger_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment