Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom Fields for Register Helper with conditional and date.
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for my Paid Memberships Pro Setup
Version: .1
Author: Paid Memberships Pro
Author URI: https://www.paidmembershipspro.com
*/
//Now start placing your customization code below this line
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists( 'pmprorh_add_registration_field' )) {
return false;
}
$fields[] = new PMProRH_Field(
'insured',
'radio',
array(
'label' => 'Insured?',
'options' => array(
'yes' => 'Yes',
'no' => 'No',
),
'required' => true,
'profile' => true,
// 'memberslistcsv' => true, /* Uncomment to include in Memberlist CSV */
// "addmember" => true, /* Uncomment if using the Admin Add Member plugin */
)
);
// "depends" => array( array( 'id' => 'newsletter_other', 'value' => '1' ) ),
$fields[] = new PMProRH_Field(
'insuretype',
'select',
array(
'depends' => array(array( 'id' => 'insured', 'value' => 'yes' ) ),
'label' => 'If yes, insurance type?',
'options' => array(
'medicaid' => 'Medicaid',
'medicare'=> 'Medicare',
'commercial'=> 'Commercial',
),
'required' => true,
'profile' => true,
// 'memberslistcsv' => true, /* Uncomment to include in Memberlist CSV */
// "addmember" => true, /* Uncomment if using the Admin Add Member plugin */
)
);
$fields[] = new PMProRH_Field(
'hhm',
'text',
array(
'label' => 'House Hold Members',
'size' => 10,
'required' => true,
'profile' => true,
// 'memberslistcsv' => true, /* Uncomment to include in Memberlist CSV */
// "addmember" => true, /* Uncomment if using the Admin Add Member plugin */
)
);
$fields[] = new PMProRH_Field(
'dob', // input name, will also be used as meta key
'date', // type of field
array(
'label' => 'Date Of Birth', // custom field label
'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
)
);
$fields[] = new PMProRH_Field(
'ssn',
'text',
array(
'label' => 'SSN',
'required' => true,
'profile' => true,
// 'memberslistcsv' => true, /* Uncomment to include in Memberlist CSV */
// "addmember" => true, /* Uncomment if using the Admin Add Member plugin */
)
);
// Source (multiselect) [Renewal, Radio, Newspaper, Television, Billboard, Other]
$fields[] = new PMProRH_Field(
'source',
'multiselect',
array(
'label' => 'Source',
'options' => array(
'renewal' => 'Renewal',
'radio'=> 'Radio',
'newspaper'=> 'Newspaper',
'television' => 'Television',
'billboard'=> 'Billboard',
'other'=> 'Other',
),
'required' => true,
'profile' => true,
// 'memberslistcsv' => true, /* Uncomment to include in Memberlist CSV */
// "addmember" => true, /* Uncomment if using the Admin Add Member plugin */
)
);
//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
You can’t perform that action at this time.