Created
October 17, 2018 00:54
-
-
Save pbrocks/210ecbcf0eab5b6b5ac24ebbe4104b15 to your computer and use it in GitHub Desktop.
New Register Helper plugin Customizations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: PMPro - Register Helper Customizations | |
* Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/ | |
* Description: Customizations for Levels 1 and 4 | |
* Version: 0.2 | |
* Author: Steve Moen & Nicola | |
* Author URI: https://www.365give.ca | |
*/ | |
// 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(); | |
$this_plugin = get_plugin_data( plugin_dir_path( __FILE__ ) . basename( __FILE__ ) ); | |
$fields[] = new PMProRH_Field( | |
'admin_html_message', | |
'html', | |
array( | |
'profile' => 'only_admin', | |
'label' => ucwords( preg_replace( '/_+/', ' ', 'admin_html_message' ) ), | |
'html' => '<p>This plugin can be found in ' . plugin_dir_path( __FILE__ ) . basename( __FILE__ ) . '. To deactivate, go to: <a href="' . admin_url() . 'plugins.php">' . admin_url() . 'plugins.php</a>, and look for the plugin named: ' . $this_plugin['Name'] . '</p>', | |
'profile' => true, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'enrolling-as', // input name, will also be used as meta key | |
'radio', // type of field | |
array( | |
'levels' => 1, | |
'label' => 'Enrolling As:', // custom field label | |
'profile' => false, // show in user profile | |
'memberslistcsv' => true, | |
'required' => true, // make this field required | |
'options' => array( // <option> elements for select field | |
'school' => 'School', // <option value="male">Male</option> | |
'classroom' => 'Classroom', // <option value="female">Female</option> | |
), | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'school-name', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'size' => 40, // input size | |
'levels' => 1, | |
'label' => 'School Name:', // custom field label | |
'memberslistcsv' => true, | |
'profile' => false, // show in user profile | |
'required' => true, // make this field required | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'school-location', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'size' => 40, // input size | |
'levels' => 1, | |
'label' => 'School Location (city, country):', // custom field label | |
'memberslistcsv' => true, | |
'profile' => false, // show in user profile | |
'required' => true, // make this field required | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'number-students', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'size' => 40, // input size | |
'levels' => 1, | |
'label' => 'Number of students participating in the 365Challenge:', // custom field label | |
'memberslistcsv' => true, | |
'profile' => false, // show in user profile | |
'required' => true, // make this field required | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'grade-level', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'size' => 40, // input size | |
'levels' => 1, | |
'label' => 'Grade/level of students:', // custom field label | |
'memberslistcsv' => true, | |
'profile' => false, // show in user profile | |
'required' => true, // make this field required | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'age-students', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'size' => 40, // input size | |
'levels' => 1, | |
'label' => 'Age of students:', // custom field label | |
'profile' => false, // show in user profile | |
'required' => true, // make this field required | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'type-club', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'size' => 40, // input size | |
'levels' => 4, | |
'label' => 'Type of Community group/club:', // custom field label | |
'profile' => false, // show in user profile | |
'required' => true, // make this field required | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'number-participants', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'size' => 40, // input size | |
'levels' => 4, | |
'label' => 'Number of participants:', // custom field label | |
'profile' => false, // show in user profile | |
'required' => true, // make this field required | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'participant-age', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'size' => 40, // input size | |
'levels' => 4, | |
'label' => 'Participant Average age or Age Range:', // custom field label | |
'profile' => false, // show in user profile | |
'required' => true, // make this field required | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'club-location', // input name, will also be used as meta key | |
'text', // type of field | |
array( | |
'size' => 40, // input size | |
'levels' => 4, | |
'label' => 'Club location (city, country):', // custom field label | |
'profile' => false, // show in user profile | |
'required' => true, // make this field required | |
) | |
); | |
// 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